Bring up to date with master

This commit is contained in:
Ian Duffy 2013-08-31 00:25:48 +01:00
commit bdba0ddeed
1201 changed files with 86556 additions and 30780 deletions

View File

@ -213,6 +213,13 @@ Install needed packages:
$ yum install cloud-agent # agent (kvm)
$ yum install cloud-usage # usage server
## Installing CloudMonkey CLI
CloudMonkey is a CLI for Apache CloudStack. It was earlier in `tools/cli` within
the source code but now it has its own repository:
https://git-wip-us.apache.org/repos/asf?p=cloudstack-cloudmonkey.git
## Notes
If you will be using Xen as your hypervisor, please download [vhd-util](http://download.cloud.com.s3.amazonaws.com/tools/vhd-util)

13
LICENSE
View File

@ -306,7 +306,7 @@ Within the scripts/vm/hypervisor/xenserver directory
from OpenStack, LLC http://www.openstack.org
swift
Within the tools/appliance/definitions/{devcloud,systemvmtemplate,systemvmtemplate64} directories
Within the tools/appliance/definitions/{devcloud,systemvmtemplate,systemvmtemplate64} directory
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Copyright (c) 2010-2012 Patrick Debois
@ -460,7 +460,7 @@ Within the ui/lib directory
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Copyright (c) 2006 - 2011 Jörn Zaefferer
Copyright (c) 2006 - 2011 Jörn Zaefferer
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@ -655,7 +655,7 @@ Within the ui/lib/jquery-ui directory
Within the ui/lib/qunit directory
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Copyright (c) 2012 John Resig, Jörn Zaefferer
Copyright (c) 2012 John Resig, Jörn Zaefferer
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@ -686,3 +686,10 @@ Within the utils/src/com/cloud/utils/db directory
from Clinton Begin http://code.google.com/p/mybatis/
ScriptRunner.java from http://code.google.com/p/mybatis/
Within the utils/src/org/apache/commons/httpclient/contrib/ssl directory
licensed under the Apache License, Version 2 http://www.apache.org/licenses/LICENSE-2.0.txt (as above)
Copyright (c) 2007 The Apache Software Foundation
from The Apache Software Foundation http://www.apache.org/
EasySSLProtocolSocketFactory.java
EasyX509TrustManager.java

View File

@ -16,4 +16,4 @@
# under the License.
configureSimulator=com.cloud.api.commands.ConfigureSimulator;1
configureSimulator=com.cloud.api.commands.ConfigureSimulatorCmd;1

View File

@ -94,3 +94,23 @@ domr.scripts.dir=scripts/network/domr/kvm
# libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver
# network.direct.source.mode=private
# network.direct.device=eth0
# setting to enable the cpu model to kvm guest globally.
# three option:custom,host-model and host-passthrough.
# custom - user custom the CPU model which specified by guest.cpu.model.
# host-model - identify the named CPU model which most closely matches the host,
# and then request additional CPU flags to complete the match. This should give
# close to maximum functionality/performance, which maintaining good
# reliability/compatibility if the guest is migrated to another host with slightly different host CPUs.
# host-passthrough - tell KVM to passthrough the host CPU with no modifications.
# The difference to host-model, instead of just matching feature flags,
# every last detail of the host CPU is matched. This gives absolutely best performance,
# and can be important to some apps which check low level CPU details,
# but it comes at a cost wrt migration. The guest can only be migrated to
# an exactly matching host CPU.
#
# guest.cpu.mode=custom|host-model|host-passthrough
# This param is only valid if guest.cpu.mode=custom,
# for examples:"Conroe" "Penryn", "Nehalem", "Westmere", "pentiumpro" and so
# on,run virsh capabilities for more details.
# guest.cpu.model=

View File

@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
@ -39,14 +39,12 @@
<dependency>
<groupId>commons-daemon</groupId>
<artifactId>commons-daemon</artifactId>
<version>${cs.daemon.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>generate-resource</id>
@ -98,7 +96,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>

View File

@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
@ -34,12 +34,27 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${cs.gson.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-db</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -27,6 +27,10 @@ import com.cloud.agent.api.LogLevel.Log4jLevel;
*/
public abstract class Command {
public static enum OnError {
Continue, Stop
}
public static final String HYPERVISOR_TYPE = "hypervisorType";
// allow command to carry over hypervisor or other environment related context info

View File

@ -41,6 +41,7 @@ public class VolumeTO implements InternalIdentity {
private Long bytesWriteRate;
private Long iopsReadRate;
private Long iopsWriteRate;
private Long chainSize;
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
this.id = id;
@ -77,6 +78,7 @@ public class VolumeTO implements InternalIdentity {
this.storagePoolUuid = pool.getUuid();
this.mountPoint = volume.getFolder();
this.chainInfo = volume.getChainInfo();
this.chainSize = volume.getVmSnapshotChainSize();
if (volume.getDeviceId() != null)
this.deviceId = volume.getDeviceId();
}
@ -170,4 +172,11 @@ public class VolumeTO implements InternalIdentity {
return iopsWriteRate;
}
public Long getChainSize() {
return chainSize;
}
public void setChainSize(Long chainSize) {
this.chainSize = chainSize;
}
}

View File

@ -20,11 +20,6 @@ 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.network.CreateNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
@ -48,17 +43,23 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
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.InvalidParameterValueException;
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;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
public interface ConfigurationService {
@ -252,30 +253,12 @@ public interface ConfigurationService {
boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd);
NetworkOffering getNetworkOffering(long id);
Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
Account getVlanAccount(long vlanId);
List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
DataCenter getZone(long id);
ServiceOffering getServiceOffering(long serviceOfferingId);
Long getDefaultPageSize();
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
DiskOffering getDiskOffering(long diskOfferingId);
/**
* @param offering
* @return
*/
boolean isOfferingForVpc(NetworkOffering offering);
PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);

View File

@ -14,18 +14,21 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.server;
package com.cloud.consoleproxy;
import java.util.List;
import java.util.Map;
import com.cloud.api.commands.ConfigureSimulator;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.ConsoleProxy;
public class ManagementServerSimulatorImpl extends ManagementServerImpl {
@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmdList = super.getCommands();
cmdList.add(ConfigureSimulator.class);
return cmdList;
}
public interface ConsoleProxyAllocator extends Adapter {
/**
* Finds the least loaded console proxy.
* @param candidates
* @param loadInfo
* @param dataCenterId
* @return id of the console proxy to use or null if none.
*/
public Long allocProxy(List<? extends ConsoleProxy> candidates, Map<Long, Integer> loadInfo, long dataCenterId);
}

View File

@ -191,6 +191,13 @@ public interface DeploymentPlanner extends Adapter {
_podIds.add(podId);
}
public void addPodList(Collection<Long> podList) {
if (_podIds == null) {
_podIds = new HashSet<Long>();
}
_podIds.addAll(podList);
}
public void addCluster(long clusterId) {
if (_clusterIds == null) {
_clusterIds = new HashSet<Long>();

View File

@ -19,7 +19,8 @@ package com.cloud.event;
import java.util.HashMap;
import java.util.Map;
import com.cloud.configuration.Configuration;
import org.apache.cloudstack.config.Configuration;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.StorageNetworkIpRange;
@ -69,7 +70,7 @@ public class EventTypes {
public static final String EVENT_VM_REBOOT = "VM.REBOOT";
public static final String EVENT_VM_UPDATE = "VM.UPDATE";
public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
public static final String EVENT_VM_SCALE = "VM.SCALE";
public static final String EVENT_VM_DYNAMIC_SCALE = "VM.DYNAMIC.SCALE";
public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
public static final String EVENT_VM_RESETSSHKEY = "VM.RESETSSHKEY";
public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
@ -92,7 +93,6 @@ public class EventTypes {
public static final String EVENT_PROXY_STOP = "PROXY.STOP";
public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
public static final String EVENT_PROXY_HA = "PROXY.HA";
public static final String EVENT_PROXY_SCALE = "PROXY.SCALE";
// VNC Console Events
@ -217,7 +217,6 @@ public class EventTypes {
public static final String EVENT_SSVM_STOP = "SSVM.STOP";
public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
public static final String EVENT_SSVM_HA = "SSVM.HA";
public static final String EVENT_SSVM_SCALE = "SSVM.SCALE";
// Service Offerings
public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
@ -443,6 +442,8 @@ public class EventTypes {
public static final String EVENT_DEDICATE_RESOURCE_RELEASE = "DEDICATE.RESOURCE.RELEASE";
public static final String EVENT_CLEANUP_VM_RESERVATION = "VM.RESERVATION.CLEANUP";
public static final String EVENT_UCS_ASSOCIATED_PROFILE = "UCS.ASSOCIATEPROFILE";
static {

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.hypervisor;
import com.cloud.storage.Storage.ImageFormat;
public class Hypervisor {
public static enum HypervisorType {
@ -63,6 +65,26 @@ public class Hypervisor {
return HypervisorType.None;
}
}
/**
* This method really needs to be part of the properties of the hypervisor type itself.
*
* @param hyperType
* @return
*/
public static ImageFormat getSupportedImageFormat(HypervisorType hyperType) {
if (hyperType == HypervisorType.XenServer) {
return ImageFormat.VHD;
} else if (hyperType == HypervisorType.KVM) {
return ImageFormat.QCOW2;
} else if (hyperType == HypervisorType.VMware) {
return ImageFormat.OVA;
} else if (hyperType == HypervisorType.Ovm) {
return ImageFormat.RAW;
} else {
return null;
}
}
}
}

View File

@ -61,8 +61,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Service Connectivity = new Service("Connectivity");
private String name;
private Capability[] caps;
private final String name;
private final Capability[] caps;
public Service(String name, Capability... caps) {
this.name = name;
@ -123,13 +123,13 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Provider SecurityGroupProvider = new Provider("SecurityGroupProvider", false);
public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false);
public static final Provider None = new Provider("None", false);
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
// 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;
private boolean isExternal;
private final String name;
private final boolean isExternal;
public Provider(String name, boolean isExternal) {
this.name = name;
@ -182,7 +182,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Capability LbSchemes = new Capability("LbSchemes");
public static final Capability DhcpAccrossMultipleSubnets = new Capability("DhcpAccrossMultipleSubnets");
private String name;
private final String name;
public Capability(String name) {
this.name = name;
@ -247,8 +247,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
private String ip6Address;
public IpAddresses(String ip4Address, String ip6Address) {
this.setIp4Address(ip4Address);
this.setIp6Address(ip6Address);
setIp4Address(ip4Address);
setIp6Address(ip6Address);
}
public String getIp4Address() {
@ -297,6 +297,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
long getNetworkOfferingId();
@Override
State getState();
long getRelated();
@ -325,6 +326,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
boolean getDisplayNetwork();
String getGuruName();
/**
* @return
*/

View File

@ -23,68 +23,70 @@ import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
public class NetworkProfile implements Network {
private long id;
private String uuid;
private long dataCenterId;
private long ownerId;
private long domainId;
private final long id;
private final String uuid;
private final long dataCenterId;
private final long ownerId;
private final long domainId;
private String dns1;
private String dns2;
private URI broadcastUri;
private State state;
private String name;
private Mode mode;
private BroadcastDomainType broadcastDomainType;
private final State state;
private final String name;
private final Mode mode;
private final BroadcastDomainType broadcastDomainType;
private TrafficType trafficType;
private String gateway;
private String cidr;
private String networkCidr;
private String ip6Gateway;
private String ip6Cidr;
private long networkOfferingId;
private long related;
private String displayText;
private String reservationId;
private String networkDomain;
private Network.GuestType guestType;
private final String gateway;
private final String cidr;
private final String networkCidr;
private final String ip6Gateway;
private final String ip6Cidr;
private final long networkOfferingId;
private final long related;
private final String displayText;
private final String reservationId;
private final String networkDomain;
private final Network.GuestType guestType;
private Long physicalNetworkId;
private ACLType aclType;
private boolean restartRequired;
private boolean specifyIpRanges;
private Long vpcId;
private boolean displayNetwork;
private final ACLType aclType;
private final boolean restartRequired;
private final boolean specifyIpRanges;
private final Long vpcId;
private final boolean displayNetwork;
private Long networkAclId;
private final String guruName;
public NetworkProfile(Network network) {
this.id = network.getId();
this.uuid = network.getUuid();
this.broadcastUri = network.getBroadcastUri();
this.dataCenterId = network.getDataCenterId();
this.ownerId = network.getAccountId();
this.state = network.getState();
this.name = network.getName();
this.mode = network.getMode();
this.broadcastDomainType = network.getBroadcastDomainType();
this.trafficType = network.getTrafficType();
this.gateway = network.getGateway();
this.cidr = network.getCidr();
this.networkCidr = network.getNetworkCidr();
this.ip6Gateway = network.getIp6Gateway();
this.ip6Cidr = network.getIp6Cidr();
this.networkOfferingId = network.getNetworkOfferingId();
this.related = network.getRelated();
this.displayText = network.getDisplayText();
this.reservationId = network.getReservationId();
this.networkDomain = network.getNetworkDomain();
this.domainId = network.getDomainId();
this.guestType = network.getGuestType();
this.physicalNetworkId = network.getPhysicalNetworkId();
this.aclType = network.getAclType();
this.restartRequired = network.isRestartRequired();
this.specifyIpRanges = network.getSpecifyIpRanges();
this.vpcId = network.getVpcId();
this.displayNetwork = network.getDisplayNetwork();
this.networkAclId = network.getNetworkACLId();
id = network.getId();
uuid = network.getUuid();
broadcastUri = network.getBroadcastUri();
dataCenterId = network.getDataCenterId();
ownerId = network.getAccountId();
state = network.getState();
name = network.getName();
mode = network.getMode();
broadcastDomainType = network.getBroadcastDomainType();
trafficType = network.getTrafficType();
gateway = network.getGateway();
cidr = network.getCidr();
networkCidr = network.getNetworkCidr();
ip6Gateway = network.getIp6Gateway();
ip6Cidr = network.getIp6Cidr();
networkOfferingId = network.getNetworkOfferingId();
related = network.getRelated();
displayText = network.getDisplayText();
reservationId = network.getReservationId();
networkDomain = network.getNetworkDomain();
domainId = network.getDomainId();
guestType = network.getGuestType();
physicalNetworkId = network.getPhysicalNetworkId();
aclType = network.getAclType();
restartRequired = network.isRestartRequired();
specifyIpRanges = network.getSpecifyIpRanges();
vpcId = network.getVpcId();
displayNetwork = network.getDisplayNetwork();
networkAclId = network.getNetworkACLId();
guruName = network.getGuruName();
}
public String getDns1() {
@ -103,6 +105,11 @@ public class NetworkProfile implements Network {
this.dns2 = dns2;
}
@Override
public String getGuruName() {
return guruName;
}
public void setBroadcastUri(URI broadcastUri) {
this.broadcastUri = broadcastUri;
}
@ -252,12 +259,12 @@ public class NetworkProfile implements Network {
@Override
public void setNetworkACLId(Long networkACLId) {
this.networkAclId = networkACLId;
networkAclId = networkACLId;
}
@Override
public void setTrafficType(TrafficType type) {
this.trafficType = type;
trafficType = type;
}
@Override

View File

@ -87,7 +87,7 @@ public interface NetworkService {
Long startIndex, Long pageSize, String name);
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags,
String newVnetRangeString, String state, String removeVlan);
String newVnetRangeString, String state);
boolean deletePhysicalNetwork(Long id);

View File

@ -55,13 +55,57 @@ public class Networks {
* Different types of broadcast domains.
*/
public enum BroadcastDomainType {
Native(null, null),
Vlan("vlan", Integer.class),
Native(null, null) {
@Override
public <T> URI toUri(T value) {
try {
if (value.toString().contains("://"))
return new URI(value.toString());
else
// strange requirement but this is how the code expects it
return new URI("vlan://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
}
}
},
Vlan("vlan", Integer.class) {
@Override
public <T> URI toUri(T value) {
try {
if (value.toString().contains("://"))
return new URI(value.toString());
else
return new URI("vlan://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException(
"Unable to convert to broadcast URI: " + value);
}
}
},
Vswitch("vs", String.class),
LinkLocal(null, null),
Vnet("vnet", Long.class),
Storage("storage", Integer.class),
Lswitch("lswitch", String.class),
Lswitch("lswitch", String.class) {
@Override
public <T> URI toUri(T value) {
try {
return new URI("lswitch",value.toString(),null,null);
} catch (URISyntaxException e) {
throw new CloudRuntimeException(
"Unable to convert to broadcast URI: " + value);
}
}
/**
* gets scheme specific part instead of host
*/
@Override
public String getValueFrom(URI uri) {
return uri.getSchemeSpecificPart();
}
},
Mido("mido", String.class),
Pvlan("pvlan", String.class),
UnDecided(null, null);
@ -90,30 +134,53 @@ public class Networks {
return type;
}
/**
* The default implementation of toUri returns an uri with the scheme and value as host
*
* @param value will be put in the host field
* @return the resulting URI
*/
public <T> URI toUri(T value) {
try {
// do we need to check that value does not contain a scheme
// part?
if (value.toString().contains(":"))
return new URI(value.toString());
else
return new URI(scheme, value.toString(), null);
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException(
"Unable to convert to broadcast URI: " + value);
}
}
public static BroadcastDomainType getTypeOf(URI uri) {
return getType(uri.getScheme());
/**
* get the enum value from this uri
*
* @param uri to get the scheme value from
* @return the scheme as BroadcastDomainType
*/
public static BroadcastDomainType getSchemeValue(URI uri) {
return toEnumValue(uri.getScheme());
}
/**
* gets the type from a string encoded uri
*
* @param str the uri string
* @return the scheme as BroadcastDomainType
* @throws URISyntaxException when the string can not be converted to URI
*/
public static BroadcastDomainType getTypeOf(String str)
throws URISyntaxException {
return getTypeOf(new URI(str));
if (com.cloud.dc.Vlan.UNTAGGED.equalsIgnoreCase(str)) {
return Native;
}
return getSchemeValue(new URI(str));
}
public static BroadcastDomainType getType(String scheme) {
/**
* converts a String to a BroadcastDomainType
*
* @param scheme convert a string representation to a BroacastDomainType
* @return the value of this
*/
public static BroadcastDomainType toEnumValue(String scheme) {
if (scheme == null) {
return UnDecided;
}
@ -125,23 +192,64 @@ public class Networks {
return UnDecided;
}
/**
* The default implementation of getValueFrom returns the host part of the uri
*
* @param uri to get the value from
* @return the host part as String
*/
public String getValueFrom(URI uri) {
return uri.getHost();
}
/**
* get the BroadcastDomain value from an arbitrary URI
* TODO what when the uri is useless
*
* @param uri the uri
* @return depending on the scheme/BroadcastDomainType
*/
public static String getValue(URI uri) {
return getSchemeValue(uri).getValueFrom(uri);
}
/**
* get the BroadcastDomain value from an arbitrary String
* TODO what when the uriString is useless
*
* @param uriString the string encoded uri
* @return depending on the scheme/BroadcastDomainType
* @throws URISyntaxException the string is not even an uri
*/
public static String getValue(String uriString)
throws URISyntaxException {
return getValue(new URI(uriString));
}
public static String getValue(URI uri) {
BroadcastDomainType type = getTypeOf(uri);
if (type == Vlan) {
// do complicated stuff for backward compatibility
try {
Long.parseLong(uri.getSchemeSpecificPart());
return uri.getSchemeSpecificPart();
} catch (NumberFormatException e) {
return uri.getHost();
/**
* encode a string into a BroadcastUri
* @param candidate the input string
* @return an URI containing an appropriate (possibly given) scheme and the value
*/
public static URI fromString(String candidate) {
try {
Long.parseLong(candidate);
return Vlan.toUri(candidate);
} catch (NumberFormatException nfe) {
if (com.cloud.dc.Vlan.UNTAGGED.equalsIgnoreCase(candidate)) {
return Native.toUri(candidate);
}
try {
URI uri = new URI(candidate);
BroadcastDomainType tiep = getSchemeValue(uri);
if (tiep.scheme.equals(uri.getScheme())) {
return uri;
} else {
throw new CloudRuntimeException("string '" + candidate + "' has an unknown BroadcastDomainType.");
}
} catch (URISyntaxException e) {
throw new CloudRuntimeException("string is not a broadcast URI: " + candidate);
}
} else {
return uri.getSchemeSpecificPart();
}
}
};
@ -188,7 +296,20 @@ public class Networks {
public enum IsolationType {
None(null, null),
Ec2("ec2", String.class),
Vlan("vlan", Integer.class),
Vlan("vlan", Integer.class) {
@Override
public <T> URI toUri(T value) {
try {
if (value.toString().contains(":"))
return new URI(value.toString());
else
return new URI("vlan", value.toString(), null, null);
} catch (URISyntaxException e) {
throw new CloudRuntimeException(
"Unable to convert to isolation URI: " + value);
}
}
},
Vswitch("vs", String.class),
Undecided(null, null),
Vnet("vnet", Long.class);
@ -211,15 +332,7 @@ public class Networks {
public <T> URI toUri(T value) {
try {
// assert(this!=Vlan ||
// value.getClass().isAssignableFrom(Integer.class)) :
// do we need to check that value does not contain a scheme
// part?
// "Why are you putting non integer into vlan url";
if (value.toString().contains(":"))
return new URI(value.toString());
else
return new URI(scheme, value.toString(), null);
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException(
"Unable to convert to isolation type URI: " + value);

View File

@ -103,9 +103,10 @@ public interface LoadBalancingRulesService {
* balancer.
*
* @param cmd
* @return list of vm instances that have been or can be applied to a load balancer
* @return list of vm instances that have been or can be applied to a load balancer along with service state,
* if the LB has health check policy created on it from cloudstack.
*/
List<? extends UserVm> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd);
Pair<List<? extends UserVm>, List<String>> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd);
/**
* List load balancer rules based on the given criteria

View File

@ -19,8 +19,6 @@ package com.cloud.network.security;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.async.AsyncInstanceCreateStatus;
public interface SecurityRule extends Identity, InternalIdentity {
public static class SecurityRuleType {
@ -28,13 +26,13 @@ public interface SecurityRule extends Identity, InternalIdentity {
public static final SecurityRuleType EgressRule = new SecurityRuleType("egress");
public SecurityRuleType(String type) {
this._type = type;
_type = type;
}
public String getType(){
return _type;
}
private String _type;
private final String _type;
}
long getSecurityGroupId();
@ -49,8 +47,6 @@ public interface SecurityRule extends Identity, InternalIdentity {
String getProtocol();
AsyncInstanceCreateStatus getCreateStatus();
Long getAllowedNetworkId();
String getAllowedSourceIpCidr();

View File

@ -56,7 +56,7 @@ public interface VpcGateway extends Identity, ControlledEntity, InternalIdentity
/**
* @return
*/
Long getNetworkId();
long getNetworkId();
/**
* @return

View File

@ -28,6 +28,12 @@ import org.apache.cloudstack.api.InternalIdentity;
*
*/
public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
enum State {
Inactive,
Active,
}
State getState();
String getUniqueName();
@ -65,6 +71,8 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
Long getMaxIops();
boolean isRecreatable();
void setBytesReadRate(Long bytesReadRate);
Long getBytesReadRate();
@ -80,4 +88,5 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
void setIopsWriteRate(Long iopsWriteRate);
Long getIopsWriteRate();
}

View File

@ -25,7 +25,7 @@ import org.apache.cloudstack.api.InternalIdentity;
/**
* offered.
*/
public interface ServiceOffering extends InfrastructureEntity, InternalIdentity, Identity {
public interface ServiceOffering extends DiskOffering, InfrastructureEntity, InternalIdentity, Identity {
public static final String consoleProxyDefaultOffUniqueName = "Cloud.com-ConsoleProxy";
public static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage";
public static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter";
@ -37,20 +37,25 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
shared
}
@Override
String getDisplayText();
@Override
Date getCreated();
@Override
String getTags();
/**
* @return user readable description
*/
@Override
String getName();
/**
* @return is this a system service offering
*/
@Override
boolean getSystemUse();
/**
@ -96,8 +101,10 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
/**
* @return whether or not the service offering requires local storage
*/
@Override
boolean getUseLocalStorage();
@Override
Long getDomainId();
/**

View File

@ -19,7 +19,9 @@ package com.cloud.server;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.cloud.exception.*;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
@ -46,9 +48,10 @@ import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
import org.apache.cloudstack.config.Configuration;
import com.cloud.alert.Alert;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.Configuration;
import com.cloud.dc.Pod;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;

View File

@ -1,50 +0,0 @@
/*
* 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.storage;
import java.util.Date;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.agent.api.to.S3TO;
public interface S3 extends InternalIdentity, Identity {
String getAccessKey();
String getSecretKey();
String getEndPoint();
String getBucketName();
Integer getHttpsFlag();
Integer getConnectionTimeout();
Integer getMaxErrorRetry();
Integer getSocketTimeout();
Date getCreated();
S3TO toS3TO();
}

View File

@ -20,8 +20,9 @@ import java.net.UnknownHostException;
import org.apache.cloudstack.api.command.admin.storage.AddImageStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateCacheStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeleteSecondaryStagingStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
@ -48,8 +49,8 @@ public interface StorageService{
*/
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
UnknownHostException, ResourceUnavailableException;
ImageStore createCacheStore(CreateCacheStoreCmd cmd);
ImageStore createSecondaryStagingStore(CreateSecondaryStagingStoreCmd cmd);
/**
* Delete the storage pool
@ -92,6 +93,8 @@ public interface StorageService{
boolean deleteImageStore(DeleteImageStoreCmd cmd);
boolean deleteSecondaryStagingStore(DeleteSecondaryStagingStoreCmd cmd);
ImageStore discoverImageStore(AddImageStoreCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
}

View File

@ -184,4 +184,5 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
*/
void setReservationId(String reserv);
Storage.ImageFormat getFormat();
Long getVmSnapshotChainSize();
}

View File

@ -20,6 +20,7 @@ package com.cloud.storage;
import java.net.URISyntaxException;
import com.cloud.exception.StorageUnavailableException;
import org.apache.cloudstack.api.command.user.volume.*;
import com.cloud.exception.ConcurrentOperationException;

View File

@ -36,7 +36,6 @@ import com.cloud.exception.InternalErrorException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.CloudRuntimeException;
public interface TemplateApiService {
@ -88,8 +87,6 @@ public interface TemplateApiService {
*/
String extract(ExtractTemplateCmd cmd) throws InternalErrorException;
VirtualMachineTemplate getTemplate(long templateId);
List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);

View File

@ -28,6 +28,10 @@ import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
enum State {
Active,
Inactive;
}
public static enum BootloaderType {
PyGrub, HVM, External, CD
@ -44,6 +48,8 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
all // all templates (only usable by admins)
}
State getState();
boolean isFeatured();
/**

View File

@ -517,7 +517,7 @@ public class ApiConstants {
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
public static final String ROUTING = "isrouting";
public static final String MAX_CONNECTIONS = "maxconnections";
public static final String SERVICE_STATE = "servicestate";
public enum HostDetails {
all, capacity, events, stats, min;
}

View File

@ -16,10 +16,8 @@
// under the License.
package org.apache.cloudstack.api;
import org.apache.cloudstack.api.response.AsyncJobResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.async.AsyncJob;
import com.cloud.user.User;
/**
@ -33,7 +31,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
public static final String snapshotHostSyncObject = "snapshothost";
public static final String gslbSyncObject = "globalserverloadbalacner";
private AsyncJob job;
private Object job;
@Parameter(name = "starteventid", type = CommandType.LONG)
private Long startEventId;
@ -56,16 +54,8 @@ public abstract class BaseAsyncCmd extends BaseCmd {
*/
public abstract String getEventDescription();
public ResponseObject getResponse(long jobId) {
AsyncJobResponse response = new AsyncJobResponse();
AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
response.setJobId(job.getUuid());
response.setResponseName(getCommandName());
return response;
}
public void setJob(AsyncJob job) {
public void setJob(Object job) {
this.job = job;
}
@ -100,7 +90,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
return null;
}
public AsyncJob getJob() {
public Object getJob() {
return job;
}

View File

@ -16,13 +16,9 @@
// under the License.
package org.apache.cloudstack.api;
import org.apache.cloudstack.api.response.CreateCmdResponse;
import com.cloud.async.AsyncJob;
import com.cloud.exception.ResourceAllocationException;
public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
@Parameter(name = "id", type = CommandType.LONG)
private Long id;
private String uuid;
@ -45,15 +41,6 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
this.uuid = uuid;
}
public String getResponse(long jobId, String objectUuid) {
CreateCmdResponse response = new CreateCmdResponse();
AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
response.setJobId(job.getUuid());
response.setId(objectUuid);
response.setResponseName(getCommandName());
return _responseGenerator.toSerializedString(response, getResponseType());
}
public String getCreateEventType() {
return null;
}

View File

@ -16,81 +16,12 @@
// under the License.
package org.apache.cloudstack.api;
import com.cloud.async.AsyncJob;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.Configuration;
import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.StorageNetworkIpRange;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;
import com.cloud.event.Event;
import com.cloud.host.Host;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.GuestVlan;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.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;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.StaticNatRule;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.org.Cluster;
import com.cloud.projects.Project;
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.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;
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.NicSecondaryIp;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.snapshot.VMSnapshot;
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;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
@ -150,7 +81,6 @@ import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
import org.apache.cloudstack.api.response.ResourceCountResponse;
import org.apache.cloudstack.api.response.ResourceLimitResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.S3Response;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceResponse;
@ -163,7 +93,6 @@ 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.StoragePoolResponse;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
@ -181,17 +110,85 @@ 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.config.Configuration;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.usage.Usage;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.StorageNetworkIpRange;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;
import com.cloud.event.Event;
import com.cloud.host.Host;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.GuestVlan;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.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;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.StaticNatRule;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.org.Cluster;
import com.cloud.projects.Project;
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.GuestOS;
import com.cloud.storage.ImageStore;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import com.cloud.storage.Snapshot;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
import com.cloud.storage.snapshot.SnapshotPolicy;
import com.cloud.storage.snapshot.SnapshotSchedule;
import com.cloud.template.VirtualMachineTemplate;
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.NicSecondaryIp;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.snapshot.VMSnapshot;
public interface ResponseGenerator {
UserResponse createUserResponse(UserAccount user);
@ -301,8 +298,6 @@ public interface ResponseGenerator {
String toSerializedString(CreateCmdResponse response, String responseType);
AsyncJobResponse createAsyncJobResponse(AsyncJob job);
EventResponse createEventResponse(Event event);
//List<EventResponse> createEventResponse(EventJoinVO... events);
@ -331,7 +326,7 @@ public interface ResponseGenerator {
List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, Long zoneId, boolean readyOnly);
// List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
// List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
//List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly);
ProjectResponse createProjectResponse(Project project);
@ -348,10 +343,6 @@ public interface ResponseGenerator {
SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine systemVM);
SwiftResponse createSwiftResponse(Swift swift);
S3Response createS3Response(S3 result);
PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result);
ServiceResponse createNetworkServiceResponse(Service service);

View File

@ -17,11 +17,9 @@
package org.apache.cloudstack.api.command.admin.cluster;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.org.Cluster;
import com.cloud.user.Account;
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.ApiErrorCode;
@ -34,8 +32,10 @@ import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.org.Cluster;
import com.cloud.user.Account;
@APICommand(name = "addCluster", description="Adds a new cluster", responseObject=ClusterResponse.class)
public class AddClusterCmd extends BaseCmd {
@ -87,10 +87,10 @@ public class AddClusterCmd extends BaseCmd {
@Parameter(name = ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, type = CommandType.STRING, required = false, description = "Type of virtual switch used for public traffic in the cluster. Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed vSwitch)")
private String vSwitchTypePublicTraffic;
@Parameter(name = ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, type = CommandType.STRING, required = false, description = "Name of virtual switch used for guest traffic in the cluster. This would override zone wide traffic label setting.")
@Parameter(name = ApiConstants.VSWITCH_NAME_GUEST_TRAFFIC, type = CommandType.STRING, required = false, description = "Name of virtual switch used for guest traffic in the cluster. This would override zone wide traffic label setting.")
private String vSwitchNameGuestTraffic;
@Parameter(name = ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, type = CommandType.STRING, required = false, description = "Name of virtual switch used for public traffic in the cluster. This would override zone wide traffic label setting.")
@Parameter(name = ApiConstants.VSWITCH_NAME_PUBLIC_TRAFFIC, type = CommandType.STRING, required = false, description = "Name of virtual switch used for public traffic in the cluster. This would override zone wide traffic label setting.")
private String vSwitchNamePublicTraffic;
public String getVSwitchTypeGuestTraffic() {

View File

@ -24,9 +24,10 @@ import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.config.Configuration;
import org.apache.log4j.Logger;
import com.cloud.configuration.Configuration;
import com.cloud.utils.Pair;
@APICommand(name = "listConfigurations", description = "Lists all configurations.", responseObject = ConfigurationResponse.class)

View File

@ -23,9 +23,10 @@ import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.config.Configuration;
import org.apache.log4j.Logger;
import com.cloud.configuration.Configuration;
import com.cloud.user.Account;
@APICommand(name = "updateConfiguration", description="Updates a configuration.", responseObject=ConfigurationResponse.class)

View File

@ -54,8 +54,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the physical network")
private String vlan;
@Parameter(name=ApiConstants.REMOVE_VLAN, type = CommandType.STRING, description ="The vlan range we want to remove")
private String removevlan;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -81,10 +79,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
return vlan;
}
public String getRemoveVlan(){
return removevlan;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -101,7 +95,7 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Override
public void execute(){
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getTags(), getVlan(), getState(), getRemoveVlan());
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getTags(), getVlan(), getState());
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -96,8 +96,6 @@ public class ListPortableIpRangesCmd extends BaseListCmd {
}
rangeResponse.setPortableIpResponses(portableIpResponses);
}
rangeResponse.setObjectName("portableiprange");
responses.add(rangeResponse);
}
}

View File

@ -60,7 +60,7 @@ public class AddImageStoreCmd extends BaseCmd {
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="the details for the image store. Example: details[0].key=accesskey&details[0].value=s389ddssaa&details[1].key=secretkey&details[1].value=8dshfsss")
private Map<String, String> details;
private Map details;
@ -81,19 +81,19 @@ public class AddImageStoreCmd extends BaseCmd {
return zoneId;
}
public Map<String, String> getDetails() {
Map<String, String> detailsMap = null;
if (details != null && !details.isEmpty()) {
detailsMap = new HashMap<String, String>();
Collection<?> props = details.values();
Iterator<?> iter = props.iterator();
while (iter.hasNext()) {
HashMap<String, String> detail = (HashMap<String, String>) iter.next();
String key = detail.get("key");
String value = detail.get("value");
detailsMap.put(key, value);
}
}
public Map<String, String> getDetails() {
Map<String, String> detailsMap = null;
if (details != null && !details.isEmpty()) {
detailsMap = new HashMap<String, String>();
Collection<?> props = details.values();
Iterator<?> iter = props.iterator();
while (iter.hasNext()) {
HashMap<String, String> detail = (HashMap<String, String>) iter.next();
String key = detail.get("key");
String value = detail.get("value");
detailsMap.put(key, value);
}
}
return detailsMap;
}
@ -139,10 +139,10 @@ public class AddImageStoreCmd extends BaseCmd {
ImageStore result = _storageService.discoverImageStore(this);
ImageStoreResponse storeResponse = null;
if (result != null ) {
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("imagestore");
this.setResponseObject(storeResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
}

View File

@ -91,31 +91,44 @@ public final class AddS3Cmd extends BaseCmd {
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException,
NetworkRuleConflictException {
ServerApiException, ConcurrentOperationException, ResourceAllocationException,
NetworkRuleConflictException {
AddImageStoreCmd cmd = new AddImageStoreCmd();
AddImageStoreCmd cmd = new AddImageStoreCmd() {
@Override
public Map<String, String> getDetails() {
Map<String, String> dm = new HashMap<String, String>();
dm.put(ApiConstants.S3_ACCESS_KEY, getAccessKey());
dm.put(ApiConstants.S3_SECRET_KEY, getSecretKey());
dm.put(ApiConstants.S3_END_POINT, getEndPoint());
dm.put(ApiConstants.S3_BUCKET_NAME, getBucketName());
if (getHttpsFlag() != null) {
dm.put(ApiConstants.S3_HTTPS_FLAG, getHttpsFlag().toString());
}
if (getConnectionTimeout() != null) {
dm.put(ApiConstants.S3_CONNECTION_TIMEOUT, getConnectionTimeout().toString());
}
if (getMaxErrorRetry() != null) {
dm.put(ApiConstants.S3_MAX_ERROR_RETRY, getMaxErrorRetry().toString());
}
if (getSocketTimeout() != null) {
dm.put(ApiConstants.S3_SOCKET_TIMEOUT, getSocketTimeout().toString());
}
return dm;
}
};
cmd.setProviderName("S3");
Map<String, String> details = new HashMap<String, String>();
details.put(ApiConstants.S3_ACCESS_KEY, this.getAccessKey());
details.put(ApiConstants.S3_SECRET_KEY, this.getSecretKey());
details.put(ApiConstants.S3_END_POINT, this.getEndPoint());
details.put(ApiConstants.S3_BUCKET_NAME, this.getBucketName());
details.put(ApiConstants.S3_HTTPS_FLAG, this.getHttpsFlag().toString());
details.put(ApiConstants.S3_CONNECTION_TIMEOUT, this.getConnectionTimeout().toString());
details.put(ApiConstants.S3_MAX_ERROR_RETRY, this.getMaxErrorRetry().toString());
details.put(ApiConstants.S3_SOCKET_TIMEOUT, this.getSocketTimeout().toString());
try{
ImageStore result = _storageService.discoverImageStore(cmd);
ImageStoreResponse storeResponse = null;
if (result != null ) {
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);

View File

@ -35,32 +35,32 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@APICommand(name = "createCacheStore", description="create cache store.", responseObject=ImageStoreResponse.class)
public class CreateCacheStoreCmd extends BaseCmd {
@APICommand(name = "createSecondaryStagingStore", description = "create secondary staging store.", responseObject = ImageStoreResponse.class)
public class CreateSecondaryStagingStoreCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddImageStoreCmd.class.getName());
private static final String s_name = "createcachestoreresponse";
private static final String s_name = "createsecondarystagingstoreresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL for the cache store")
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the URL for the staging store")
private String url;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
description="the Zone ID for the image store")
description = "the Zone ID for the staging store")
private Long zoneId;
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="the details for the image store")
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "the details for the staging store")
private Map<String, String> details;
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
required=false, description="the scope of the image store: zone only for now")
required = false, description = "the scope of the staging store: zone only for now")
private String scope;
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING,
required=false, description="the cache store provider name")
required = false, description = "the staging store provider name")
private String providerName;
/////////////////////////////////////////////////////
@ -75,25 +75,25 @@ public class CreateCacheStoreCmd extends BaseCmd {
return zoneId;
}
public Map<String, String> getDetails() {
Map<String, String> detailsMap = null;
if (details != null && !details.isEmpty()) {
detailsMap = new HashMap<String, String>();
Collection<?> props = details.values();
Iterator<?> iter = props.iterator();
while (iter.hasNext()) {
HashMap<String, String> detail = (HashMap<String, String>) iter.next();
String key = detail.get("key");
String value = detail.get("value");
detailsMap.put(key, value);
}
}
return detailsMap;
public Map<String, String> getDetails() {
Map<String, String> detailsMap = null;
if (details != null && !details.isEmpty()) {
detailsMap = new HashMap<String, String>();
Collection<?> props = details.values();
Iterator<?> iter = props.iterator();
while (iter.hasNext()) {
HashMap<String, String> detail = (HashMap<String, String>) iter.next();
String key = detail.get("key");
String value = detail.get("value");
detailsMap.put(key, value);
}
}
return detailsMap;
}
public String getScope() {
return this.scope;
}
}
public String getProviderName() {
return this.providerName;
@ -117,13 +117,13 @@ public class CreateCacheStoreCmd extends BaseCmd {
@Override
public void execute(){
try{
ImageStore result = _storageService.createCacheStore(this);
ImageStore result = _storageService.createSecondaryStagingStore(this);
ImageStoreResponse storeResponse = null;
if (result != null ) {
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
}

View File

@ -0,0 +1,79 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.admin.storage;
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.ImageStoreResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@APICommand(name = "deleteSecondaryStagingStore", description = "Deletes a secondary staging store .", responseObject = SuccessResponse.class, since = "4.2.0")
public class DeleteSecondaryStagingStoreCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteSecondaryStagingStoreCmd.class.getName());
private static final String s_name = "deletesecondarystagingstoreresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ImageStoreResponse.class,
required = true, description = "the staging store ID")
private Long id;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public Long getId() {
return id;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
boolean result = _storageService.deleteSecondaryStagingStore(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete secondary staging store");
}
}
}

View File

@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
public class ListImageStoresCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListImageStoresCmd.class.getName());
private static final String s_name = "listimagestoreresponse";
private static final String s_name = "listimagestoresresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -25,31 +25,31 @@ import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
@APICommand(name = "listCacheStores", description="Lists cache stores.", responseObject=ImageStoreResponse.class, since = "4.2.0")
public class ListCacheStoresCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListCacheStoresCmd.class.getName());
@APICommand(name = "listSecondaryStagingStores", description = "Lists secondary staging stores.", responseObject = ImageStoreResponse.class, since = "4.2.0")
public class ListSecondaryStagingStoresCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListSecondaryStagingStoresCmd.class.getName());
private static final String s_name = "listcachestoreresponse";
private static final String s_name = "listsecondarystagingstoreresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the cache store")
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the staging store")
private String storeName;
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, description="the cache store protocol")
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "the staging store protocol")
private String protocol;
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING, description="the cache store provider")
@Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "the staging store provider")
private String provider;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
description="the Zone ID for the cache store")
description = "the Zone ID for the staging store")
private Long zoneId;
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = ImageStoreResponse.class,
description="the ID of the cache store")
description = "the ID of the staging store")
private Long id;
/////////////////////////////////////////////////////
@ -97,7 +97,7 @@ public class ListCacheStoresCmd extends BaseListCmd {
@Override
public void execute(){
ListResponse<ImageStoreResponse> response = _queryService.searchForCacheStores(this);
ListResponse<ImageStoreResponse> response = _queryService.searchForSecondaryStagingStores(this);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}

View File

@ -47,6 +47,13 @@ public class UpdateStoragePoolCmd extends BaseCmd {
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma-separated list of tags for the storage pool")
private List<String> tags;
@Parameter(name=ApiConstants.CAPACITY_IOPS, type=CommandType.LONG,
required=false, description="IOPS CloudStack can provision from this storage pool")
private Long capacityIops;
@Parameter(name=ApiConstants.CAPACITY_BYTES, type=CommandType.LONG,
required=false, description="bytes CloudStack can provision from this storage pool")
private Long capacityBytes;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -60,6 +67,14 @@ public class UpdateStoragePoolCmd extends BaseCmd {
return tags;
}
public Long getCapacityIops() {
return capacityIops;
}
public Long getCapacityBytes() {
return capacityBytes;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,122 @@
// 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.swift;
import java.util.HashMap;
import java.util.Map;
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.command.admin.storage.AddImageStoreCmd;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.DiscoveryException;
import com.cloud.storage.ImageStore;
import com.cloud.user.Account;
@APICommand(name = "addSwift", description = "Adds Swift.", responseObject = ImageStoreResponse.class, since="3.0.0")
public class AddSwiftCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddSwiftCmd.class.getName());
private static final String s_name = "addswiftresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the URL for swift")
private String url;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account for swift")
private String account;
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the username for swift")
private String username;
@Parameter(name = ApiConstants.KEY, type = CommandType.STRING, description = " key for the user for swift")
private String key;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getUrl() {
return url;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
public String getAccount() {
return account;
}
public String getUsername() {
return username;
}
public String getKey() {
return key;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
AddImageStoreCmd cmd = new AddImageStoreCmd() {
@Override
public Map<String, String> getDetails() {
Map<String, String> dm = new HashMap<String, String>();
dm.put(ApiConstants.ACCOUNT, getAccount());
dm.put(ApiConstants.USERNAME, getUsername());
dm.put(ApiConstants.KEY, getKey());
return dm;
}
};
cmd.setProviderName("Swift");
cmd.setUrl(this.getUrl());
try{
ImageStore result = _storageService.discoverImageStore(cmd);
ImageStoreResponse storeResponse = null;
if (result != null ) {
storeResponse = _responseGenerator.createImageStoreResponse(result);
storeResponse.setResponseName(getCommandName());
storeResponse.setObjectName("secondarystorage");
this.setResponseObject(storeResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Swift secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -0,0 +1,70 @@
// 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.swift;
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.command.admin.storage.ListImageStoresCmd;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@APICommand(name = "listSwifts", description = "List Swift.", responseObject = ImageStoreResponse.class, since="3.0.0")
public class ListSwiftsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListSwiftsCmd.class.getName());
private static final String s_name = "listswiftsresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the id of the swift")
private Long id;
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
ListImageStoresCmd cmd = new ListImageStoresCmd();
cmd.setProvider("Swift");
ListResponse<ImageStoreResponse> response = _queryService.searchForImageStores(cmd);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -16,19 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.admin.systemvm;
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.HostResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InvalidParameterValueException;
@ -38,8 +25,18 @@ import com.cloud.exception.VirtualMachineMigrationException;
import com.cloud.host.Host;
import com.cloud.user.Account;
import com.cloud.vm.VirtualMachine;
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.HostResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
@APICommand(name = "migrateSystemVm", description="Attempts Migration of a system virtual machine to the host specified.", responseObject=SystemVmInstanceResponse.class)
@APICommand(name = "migrateSystemVm", description="Attempts Migration of a system virtual machine to the host specified.", responseObject=SystemVmResponse.class)
public class MigrateSystemVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(MigrateSystemVMCmd.class.getName());
@ -113,7 +110,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
if (migratedVm != null) {
// return the generic system VM instance response
SystemVmInstanceResponse response = _responseGenerator.createSystemVmInstanceResponse(migratedVm);
SystemVmResponse response = _responseGenerator.createSystemVmResponse(migratedVm);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {

View File

@ -16,17 +16,25 @@
// under the License.
package org.apache.cloudstack.api.command.admin.systemvm;
import com.cloud.event.EventTypes;
import com.cloud.exception.*;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.*;
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.command.user.vm.UpgradeVMCmd;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ManagementServerException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.VirtualMachineMigrationException;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
import com.cloud.vm.VirtualMachine;
@ -85,7 +93,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
public void execute(){
CallContext.current().setEventDetails("SystemVm Id: "+getId());
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
}
@ -109,25 +117,19 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
if (result != null) {
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
}
}
@Override
public String getEventType() {
VirtualMachine.Type type = _mgr.findSystemVMTypeById(getId());
if(type == VirtualMachine.Type.ConsoleProxy){
return EventTypes.EVENT_PROXY_SCALE;
}
else{
return EventTypes.EVENT_SSVM_SCALE;
}
return EventTypes.EVENT_VM_UPGRADE;
}
@Override
public String getEventDescription() {
return "scaling system vm: " + getId() + " to service offering: " + getServiceOfferingId();
return "Upgrading system vm: " + getId() + " to service offering: " + getServiceOfferingId();
}
}

View File

@ -16,6 +16,8 @@
// under the License.
package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@ -27,8 +29,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
@ -88,7 +88,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
public void execute(){
CallContext.current().setEventDetails("Vm Id: "+getId());
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
}
@ -97,7 +97,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
if (result != null) {
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}

View File

@ -35,7 +35,7 @@ import org.apache.log4j.Logger;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
@APICommand(name = "assignVirtualMachine", description="Assign a VM from one account to another under the same domain. This API is available for Basic zones with security groups and Advance zones with guest networks. The VM is restricted to move between accounts under same domain.", responseObject=UserVmResponse.class, since="3.0.0")
@APICommand(name = "assignVirtualMachine", description="Change ownership of a VM from one account to another. This API is available for Basic zones with security groups and Advanced zones with guest networks. A root administrator can reassign a VM from any account to any other account in any domain. A domain administrator can reassign a VM to any account in the same domain.", responseObject=UserVmResponse.class, since="3.0.0")
public class AssignVMCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AssignVMCmd.class.getName());

View File

@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.address;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
@ -36,8 +38,6 @@ import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.event.EventTypes;
@ -51,6 +51,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.vpc.Vpc;
import com.cloud.offering.NetworkOffering;
import com.cloud.projects.Project;
import com.cloud.user.Account;
@ -163,7 +164,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
return null;
}
DataCenter zone = _configService.getZone(zoneId);
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
if (zone.getNetworkType() == NetworkType.Advanced) {
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
_accountService.getAccount(getEntityOwnerId()));
@ -211,6 +212,20 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
}
} else if (networkId != null){
Network network = _networkService.getNetwork(networkId);
if (network == null) {
throw new InvalidParameterValueException("Unable to find network by network id specified");
}
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
// Since the basic zone network is owned by 'Root' domain, domain access checkers will fail for the
// accounts in non-root domains while acquiring public IP. So add an exception for the 'Basic' zone
// shared network with EIP/ELB service.
return caller.getAccountId();
}
return network.getAccountId();
} else if (vpcId != null) {
Vpc vpc = _vpcService.getVpc(getVpcId());
@ -263,8 +278,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
}
if (ip != null) {
this.setEntityId(ip.getId());
this.setEntityUuid(ip.getUuid());
setEntityId(ip.getId());
setEntityUuid(ip.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
}
@ -294,7 +309,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
if (result != null) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
ipResponse.setResponseName(getCommandName());
this.setResponseObject(ipResponse);
setResponseObject(ipResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
}

View File

@ -116,11 +116,11 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
return otherDeployParams;
}
public Long getAutoscaleUserId() {
public long getAutoscaleUserId() {
if (autoscaleUserId != null) {
return autoscaleUserId;
} else {
return CallContext.current().getCallingAccount().getId();
return CallContext.current().getCallingUserId();
}
}

View File

@ -18,10 +18,11 @@ package org.apache.cloudstack.api.command.user.config;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.response.CapabilitiesResponse;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@ -52,6 +53,7 @@ public class ListCapabilitiesCmd extends BaseCmd {
response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired"));
response.setAllowUsersCreateProjects((Boolean)capabilities.get("allowusercreateprojects"));
response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled"));
if (capabilities.containsKey("apiLimitInterval")) {
response.setApiLimitInterval((Integer) capabilities.get("apiLimitInterval"));
}

View File

@ -256,7 +256,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
@Override
public String getEventDescription() {
IpAddress ip = _networkService.getIp(ipAddressId);
return ("Createing firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol());
return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol());
}
@Override

View File

@ -26,6 +26,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.IpAddress;
import com.cloud.user.Account;
@ -127,4 +128,22 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCmd {
// throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update port forwarding rule");
// }
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
return getIp().getAssociatedWithNetworkId();
}
private IpAddress getIp() {
IpAddress ip = _networkService.getIp(publicIpId);
if (ip == null) {
throw new InvalidParameterValueException("Unable to find ip address by id " + publicIpId);
}
return ip;
}
}

View File

@ -22,6 +22,7 @@ import java.util.Map;
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.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
@ -32,6 +33,7 @@ import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
@ -157,5 +159,18 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
return "creating a Load Balancer Stickiness policy: " + getLBStickinessPolicyName();
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
LoadBalancer lb = _lbService.findById(getLbRuleId());
if (lb == null) {
throw new InvalidParameterValueException("Unable to find load balancer rule " + getLbRuleId() + " to create stickiness rule");
}
return lb.getNetworkId();
}
}

View File

@ -22,6 +22,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
@ -163,7 +164,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
if (zoneId != null) {
DataCenter zone = _configService.getZone(zoneId);
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
if (zone.getNetworkType() == NetworkType.Advanced) {
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
if (networks.size() == 0) {
@ -315,7 +316,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
if (account != null) {
return account.getId();
} else {
throw new InvalidParameterValueException("Unable to find account " + account + " in domain id=" + domainId);
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId);
}
} else {
throw new InvalidParameterValueException("Can't define IP owner. Either specify account/domainId or publicIpId");
@ -381,5 +382,14 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
return ApiCommandJobType.FirewallRule;
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
return getNetworkId();
}
}

View File

@ -17,6 +17,7 @@
package org.apache.cloudstack.api.command.user.loadbalancer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.cloudstack.api.APICommand;
@ -29,6 +30,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
@APICommand(name = "listLoadBalancerRuleInstances", description="List all virtual machine instances that are assigned to a load balancer rule.", responseObject=UserVmResponse.class)
public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
@ -70,12 +72,18 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
@Override
public void execute(){
List<? extends UserVm> result = _lbService.listLoadBalancerInstances(this);
Pair<List<? extends UserVm>, List<String>> vmServiceMap = _lbService.listLoadBalancerInstances(this);
List<? extends UserVm> result = vmServiceMap.first();
List<String> serviceStates = vmServiceMap.second();
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
if (result != null) {
vmResponses = _responseGenerator.createUserVmResponse("loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
}
for (int i=0;i<result.size(); i++) {
vmResponses.get(i).setServiceState(serviceStates.get(i));
}
response.setResponses(vmResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -29,6 +29,7 @@ import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.user.Account;
@ -114,4 +115,18 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update load balancer rule");
}
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
LoadBalancer lb = _lbService.findById(getId());
if (lb == null) {
throw new InvalidParameterValueException("Unable to find load balancer rule " + getId());
}
return lb.getNetworkId();
}
}

View File

@ -19,13 +19,12 @@ package org.apache.cloudstack.api.command.user.network;
import java.util.ArrayList;
import java.util.List;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
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.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
@ -34,16 +33,10 @@ import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.user.Account;
import com.cloud.utils.net.NetUtils;

View File

@ -16,17 +16,24 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;
import org.apache.log4j.Logger;
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.*;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
@ -212,7 +219,7 @@ public class CreateNetworkCmd extends BaseCmd {
}
public Long getPhysicalNetworkId() {
NetworkOffering offering = _configService.getNetworkOffering(networkOfferingId);
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
if (offering == null) {
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
}
@ -288,7 +295,7 @@ public class CreateNetworkCmd extends BaseCmd {
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
}else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network");
}

View File

@ -16,8 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.user.Account;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -25,19 +24,13 @@ 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.AccountResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.rules.FirewallRule;
import com.cloud.user.Account;
@APICommand(name = "deleteNetworkACL", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
public class DeleteNetworkACLCmd extends BaseAsyncCmd {
@ -91,7 +84,7 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL Item");
}

View File

@ -16,23 +16,21 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
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.NetworkACLResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@APICommand(name = "deleteNetworkACLList", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
@ -86,7 +84,7 @@ public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL");
}

View File

@ -159,4 +159,14 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
public String getEventType() {
return EventTypes.EVENT_NETWORK_UPDATE;
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
return id;
}
}

View File

@ -24,6 +24,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ACL;
@ -46,8 +48,6 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.event.EventTypes;
@ -443,7 +443,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
if (result != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm");
}
@ -455,17 +455,17 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
//Verify that all objects exist before passing them to the service
Account owner = _accountService.getActiveAccountById(getEntityOwnerId());
DataCenter zone = _configService.getZone(zoneId);
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
if (zone == null) {
throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
}
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
}
VirtualMachineTemplate template = _templateService.getTemplate(templateId);
VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
// Make sure a valid template ID was specified
if (template == null) {
throw new InvalidParameterValueException("Unable to use template " + templateId);
@ -473,7 +473,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
DiskOffering diskOffering = null;
if (diskOfferingId != null) {
diskOffering = _configService.getDiskOffering(diskOfferingId);
diskOffering = _entityMgr.findById(DiskOffering.class, diskOfferingId);
if (diskOffering == null) {
throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
}
@ -495,19 +495,19 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
} else {
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
}
} else {
if (zone.isSecurityGroupEnabled()) {
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
} else {
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
}
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
}
}

View File

@ -66,7 +66,7 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
private Long id;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="name of the virtual machine")
private String instanceName;
private String name;
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
description="the pod ID")
@ -130,8 +130,8 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
return id;
}
public String getInstanceName() {
return instanceName;
public String getName() {
return name;
}
public Long getPodId() {

View File

@ -86,9 +86,18 @@ public class ScaleVMCmd extends BaseAsyncCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_UPGRADE;
}
@Override
public String getEventDescription() {
return "upgrading vm: " + getId() + " to service offering: " + getServiceOfferingId();
}
@Override
public void execute(){
//UserContext.current().setEventDetails("Vm Id: "+getId());
UserVm result;
try {
result = _userVmService.upgradeVirtualMachine(this);
@ -114,14 +123,4 @@ public class ScaleVMCmd extends BaseAsyncCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm");
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_SCALE;
}
@Override
public String getEventDescription() {
return "scaling volume: " + getId() + " to service offering: " + getServiceOfferingId();
}
}

View File

@ -16,6 +16,8 @@
// under the License.
package org.apache.cloudstack.api.command.user.vm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@ -26,8 +28,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.offering.ServiceOffering;
@ -92,7 +92,7 @@ public class UpgradeVMCmd extends BaseCmd {
public void execute() throws ResourceAllocationException{
CallContext.current().setEventDetails("Vm Id: "+getId());
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
}
@ -101,7 +101,7 @@ public class UpgradeVMCmd extends BaseCmd {
if (result != null){
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade vm");
}

View File

@ -16,27 +16,21 @@
// under the License.
package org.apache.cloudstack.api.command.user.volume;
import com.cloud.server.ResourceTag;
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.SuccessResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.cloudstack.context.CallContext;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.storage.Volume;
import com.cloud.user.Account;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.SuccessResponse;
import java.util.*;
import com.cloud.event.EventTypes;
import com.cloud.server.ResourceTag;
@APICommand(name = "addResourceDetail", description="Adds detail for the Resource.", responseObject=SuccessResponse.class)
public class AddResourceDetailCmd extends BaseAsyncCmd {
@ -113,6 +107,6 @@ public class AddResourceDetailCmd extends BaseAsyncCmd {
@Override
public void execute(){
_resourceMetaDataService.addResourceMetaData(getResourceId(), getResourceType(), getDetails());
this.setResponseObject(new SuccessResponse(getCommandName()));
setResponseObject(new SuccessResponse(getCommandName()));
}
}

View File

@ -99,6 +99,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
@Override
public void execute(){
Volume result;
result = _volumeService.migrateVolume(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);

View File

@ -101,4 +101,13 @@ public class DeleteVPCCmd extends BaseAsyncCmd{
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
return getId();
}
}

View File

@ -106,4 +106,14 @@ public class RestartVPCCmd extends BaseAsyncCmd{
public String getEventDescription() {
return "restarting VPC id=" + getId();
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
return getId();
}
}

View File

@ -105,4 +105,14 @@ public class UpdateVPCCmd extends BaseAsyncCmd{
public String getEventDescription() {
return "updating VPC id=" + getId();
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
return getId();
}
}

View File

@ -19,13 +19,14 @@ package org.apache.cloudstack.api.response;
import java.util.List;
import java.util.Map;
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.serializer.Param;
import com.cloud.user.Account;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
@EntityReference(value = Account.class)
@ -189,7 +190,7 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
@Override
public String getObjectId() {
return this.id;
return id;
}
public void setId(String id) {
@ -351,7 +352,22 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
public void setNetworkAvailable(String networkAvailable) {
this.networkAvailable = networkAvailable;
}
@Override
public void setVpcLimit(String vpcLimit) {
this.vpcLimit = networkLimit;
}
@Override
public void setVpcTotal(Long vpcTotal) {
this.vpcTotal = vpcTotal;
}
@Override
public void setVpcAvailable(String vpcAvailable) {
this.vpcAvailable = vpcAvailable;
}
@Override
public void setCpuLimit(String cpuLimit) {
this.cpuLimit = cpuLimit;

View File

@ -18,17 +18,17 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
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 org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.jobs.JobInfo;
import com.cloud.async.AsyncJob;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value=AsyncJob.class)
@SuppressWarnings("unused")
@EntityReference(value = JobInfo.class)
public class AsyncJobResponse extends BaseResponse {
@SerializedName("accountid") @Param(description="the account that executed the async command")

View File

@ -16,11 +16,12 @@
// under the License.
package org.apache.cloudstack.api.response;
import com.google.gson.annotations.SerializedName;
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 CapabilitiesResponse extends BaseResponse {
@ -46,6 +47,9 @@ public class CapabilitiesResponse extends BaseResponse {
"create disk from disk offering with custom size")
private Long diskOffMaxSize;
@SerializedName("regionsecondaryenabled") @Param(description = "true if region wide secondary is enabled, false otherwise")
private boolean regionSecondaryEnabled;
@SerializedName("apilimitinterval") @Param(description="time interval (in seconds) to reset api count")
private Integer apiLimitInterval;
@ -81,6 +85,10 @@ public class CapabilitiesResponse extends BaseResponse {
this.diskOffMaxSize = diskOffMaxSize;
}
public void setRegionSecondaryEnabled(boolean regionSecondaryEnabled){
this.regionSecondaryEnabled = regionSecondaryEnabled;
}
public void setApiLimitInterval(Integer apiLimitInterval) {
this.apiLimitInterval = apiLimitInterval;
}

View File

@ -16,9 +16,14 @@
// under the License.
package org.apache.cloudstack.api.response;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
public class CreateCmdResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
private String id;
public String getId() {

View File

@ -91,6 +91,8 @@ public class NetworkOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.EGRESS_DEFAULT_POLICY) @Param(description="true if network offering supports persistent networks, false otherwise")
private Boolean egressDefaultPolicy;
@SerializedName(ApiConstants.MAX_CONNECTIONS) @Param(description = "maximum number of concurrents connections to be handled by lb")
private Integer concurrentConnections;
public void setId(String id) {
this.id = id;
@ -173,4 +175,8 @@ public class NetworkOfferingResponse extends BaseResponse {
this.egressDefaultPolicy = egressDefaultPolicy;
}
public void setConcurrentConnections(Integer concurrentConnections) {
this.concurrentConnections = concurrentConnections;
}
}

View File

@ -76,6 +76,9 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@SerializedName("networkofferingdisplaytext") @Param(description="display text of the network offering the network is created from")
private String networkOfferingDisplayText;
@SerializedName("networkofferingconservemode") @Param(description="true if network offering is ip conserve mode enabled")
private Boolean networkOfferingConserveMode;
@SerializedName("networkofferingavailability") @Param(description="availability of the network offering the network is created from")
private String networkOfferingAvailability;
@ -247,7 +250,11 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
public void setNetworkOfferingDisplayText(String networkOfferingDisplayText) {
this.networkOfferingDisplayText = networkOfferingDisplayText;
}
public void setNetworkOfferingConserveMode(Boolean networkOfferingConserveMode) {
this.networkOfferingConserveMode = networkOfferingConserveMode;
}
public void setDisplaytext(String displaytext) {
this.displaytext = displaytext;
}

View File

@ -19,13 +19,14 @@ package org.apache.cloudstack.api.response;
import java.util.ArrayList;
import java.util.List;
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.projects.Project;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value=Project.class)
@SuppressWarnings("unused")
@ -182,7 +183,7 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
}
public void setOwner(String owner) {
this.ownerName = owner;
ownerName = owner;
}
public void setState(String state) {
@ -194,7 +195,7 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
}
public void addTag(ResourceTagResponse tag){
this.tags.add(tag);
tags.add(tag);
}
@Override
@ -296,7 +297,22 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
public void setNetworkAvailable(String networkAvailable) {
this.networkAvailable = networkAvailable;
}
@Override
public void setVpcLimit(String vpcLimit) {
this.vpcLimit = networkLimit;
}
@Override
public void setVpcTotal(Long vpcTotal) {
this.vpcTotal = vpcTotal;
}
@Override
public void setVpcAvailable(String vpcAvailable) {
this.vpcAvailable = vpcAvailable;
}
@Override
public void setCpuLimit(String cpuLimit) {
this.cpuLimit = cpuLimit;

View File

@ -35,6 +35,12 @@ public class RegionResponse extends BaseResponse {
@SerializedName(ApiConstants.END_POINT) @Param(description="the end point of the region")
private String endPoint;
@SerializedName("gslbserviceenabled") @Param(description="true if GSLB service is enabled in the region, false otherwise")
private boolean gslbServiceEnabled;
@SerializedName("portableipserviceenabled") @Param(description="true if security groups support is enabled, false otherwise")
private boolean portableipServiceEnabled;
public Integer getId() {
return id;
}
@ -59,4 +65,11 @@ public class RegionResponse extends BaseResponse {
this.endPoint = endPoint;
}
}
public void setGslbServiceEnabled(boolean gslbServiceEnabled) {
this.gslbServiceEnabled = gslbServiceEnabled;
}
public void setPortableipServiceEnabled(boolean portableipServiceEnabled) {
this.portableipServiceEnabled = portableipServiceEnabled;
}
}

View File

@ -29,6 +29,12 @@ public interface ResourceLimitAndCountResponse {
public void setNetworkAvailable(String networkAvailable);
public void setVpcLimit(String vpcLimit);
public void setVpcTotal(Long vpcTotal);
public void setVpcAvailable(String vpcAvailable);
public void setCpuLimit(String cpuLimit);
public void setCpuTotal(Long cpuTotal);

View File

@ -1,218 +0,0 @@
/*
* 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 static org.apache.cloudstack.api.ApiConstants.ID;
import static org.apache.cloudstack.api.ApiConstants.S3_ACCESS_KEY;
import static org.apache.cloudstack.api.ApiConstants.S3_BUCKET_NAME;
import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TIMEOUT;
import static org.apache.cloudstack.api.ApiConstants.S3_END_POINT;
import static org.apache.cloudstack.api.ApiConstants.S3_HTTPS_FLAG;
import static org.apache.cloudstack.api.ApiConstants.S3_MAX_ERROR_RETRY;
import static org.apache.cloudstack.api.ApiConstants.S3_SECRET_KEY;
import static org.apache.cloudstack.api.ApiConstants.S3_SOCKET_TIMEOUT;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class S3Response extends BaseResponse {
@SerializedName(ID)
@Param(description = "The ID of the S3 configuration")
private String id;
@SerializedName(S3_ACCESS_KEY)
@Param(description = "The S3 access key")
private String accessKey;
@SerializedName(S3_SECRET_KEY)
@Param(description = "The S3 secret key")
private String secretKey;
@SerializedName(S3_END_POINT)
@Param(description = "The S3 end point")
private String endPoint;
@SerializedName(S3_BUCKET_NAME)
@Param(description = "The name of the template storage bucket")
private String bucketName;
@SerializedName(S3_HTTPS_FLAG)
@Param(description = "Connect to S3 using HTTPS?")
private Integer httpsFlag;
@SerializedName(S3_CONNECTION_TIMEOUT)
@Param(description = "The connection timeout (milliseconds)")
private Integer connectionTimeout;
@SerializedName(S3_MAX_ERROR_RETRY)
@Param(description = "The maximum number of time to retry a connection on error.")
private Integer maxErrorRetry;
@SerializedName(S3_SOCKET_TIMEOUT)
@Param(description = "The connection socket (milliseconds)")
private Integer socketTimeout;
@Override
public boolean equals(final Object thatObject) {
if (this == thatObject) {
return true;
}
if (thatObject == null || this.getClass() != thatObject.getClass()) {
return false;
}
final S3Response thatS3Response = (S3Response) thatObject;
if (this.httpsFlag != null ? !this.httpsFlag.equals(thatS3Response.httpsFlag) : thatS3Response.httpsFlag != null) {
return false;
}
if (this.accessKey != null ? !this.accessKey.equals(thatS3Response.accessKey) : thatS3Response.accessKey != null) {
return false;
}
if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatS3Response.connectionTimeout) : thatS3Response.connectionTimeout != null) {
return false;
}
if (this.endPoint != null ? !this.endPoint.equals(thatS3Response.endPoint) : thatS3Response.endPoint != null) {
return false;
}
if (this.id != null ? !this.id.equals(thatS3Response.id) : thatS3Response.id != null) {
return false;
}
if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatS3Response.maxErrorRetry) : thatS3Response.maxErrorRetry != null) {
return false;
}
if (this.secretKey != null ? !this.secretKey.equals(thatS3Response.secretKey) : thatS3Response.secretKey != null) {
return false;
}
if (this.socketTimeout != null ? !this.socketTimeout.equals(thatS3Response.socketTimeout) : thatS3Response.socketTimeout != null) {
return false;
}
if (this.bucketName != null ? !this.bucketName.equals(thatS3Response.bucketName) : thatS3Response.bucketName != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = this.id != null ? this.id.hashCode() : 0;
result = 31 * result + (this.accessKey != null ? this.accessKey.hashCode() : 0);
result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
result = 31 * result + (this.httpsFlag != null ? this.httpsFlag : 0);
result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
return result;
}
@Override
public String getObjectId() {
return this.id;
}
public void setObjectId(String id) {
this.id = id;
}
public String getAccessKey() {
return this.accessKey;
}
public void setAccessKey(final String accessKey) {
this.accessKey = accessKey;
}
public String getSecretKey() {
return this.secretKey;
}
public void setSecretKey(final String secretKey) {
this.secretKey = secretKey;
}
public String getEndPoint() {
return this.endPoint;
}
public void setEndPoint(final String endPoint) {
this.endPoint = endPoint;
}
public String getTemplateBucketName() {
return this.bucketName;
}
public void setTemplateBucketName(final String templateBucketName) {
this.bucketName = templateBucketName;
}
public Integer getHttpsFlag() {
return this.httpsFlag;
}
public void setHttpsFlag(final Integer httpsFlag) {
this.httpsFlag = httpsFlag;
}
public Integer getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(final Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public Integer getMaxErrorRetry() {
return this.maxErrorRetry;
}
public void setMaxErrorRetry(final Integer maxErrorRetry) {
this.maxErrorRetry = maxErrorRetry;
}
public Integer getSocketTimeout() {
return this.socketTimeout;
}
public void setSocketTimeout(final Integer socketTimeout) {
this.socketTimeout = socketTimeout;
}
}

View File

@ -18,7 +18,11 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
import javax.persistence.Column;
import com.google.gson.annotations.SerializedName;
import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@ -26,7 +30,6 @@ import org.apache.cloudstack.api.EntityReference;
import com.cloud.offering.ServiceOffering;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value = ServiceOffering.class)
public class ServiceOfferingResponse extends BaseResponse {
@ -102,6 +105,10 @@ public class ServiceOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.DEPLOYMENT_PLANNER) @Param(description="deployment strategy used to deploy VM.")
private String deploymentPlanner;
@SerializedName(ApiConstants.SERVICE_OFFERING_DETAILS)
@Param(description = "additional key/value details tied with this service offering", since = "4.2.0")
private Map<String, String> details;
public String getId() {
return id;
}
@ -141,7 +148,7 @@ public class ServiceOfferingResponse extends BaseResponse {
}
public void setSystemVmType(String vmtype) {
this.vm_type = vmtype;
vm_type = vmtype;
}
@ -276,4 +283,8 @@ public class ServiceOfferingResponse extends BaseResponse {
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public void setDetails(Map<String, String> details) {
this.details = details;
}
}

View File

@ -1,86 +0,0 @@
// 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.Date;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class SwiftResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of swift")
private String id;
@SerializedName(ApiConstants.URL)
@Param(description = "url for swift")
private String url;
@SerializedName(ApiConstants.CREATED)
@Param(description = "the date and time the host was created")
private Date created;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account for swift")
private String account;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the username for swift")
private String username;
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.response;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
@ -35,408 +34,624 @@ import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
@EntityReference(value={VirtualMachine.class, UserVm.class, VirtualRouter.class})
public class UserVmResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the virtual machine")
private String id;
@SerializedName(ApiConstants.ID) @Param(description="the ID of the virtual machine")
private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the virtual machine")
private String name;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the virtual machine")
private String name;
@SerializedName("displayname") @Param(description="user generated name. The name of the virtual machine is returned if no displayname exists.")
private String displayName;
@SerializedName("displayname") @Param(description="user generated name. The name of the virtual machine is returned if no displayname exists.")
private String displayName;
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account associated with the virtual machine")
private String accountName;
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account associated with the virtual machine")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vm")
private String projectId;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vm")
private String projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vm")
private String projectName;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vm")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the domain in which the virtual machine exists")
private String domainId;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the domain in which the virtual machine exists")
private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the name of the domain in which the virtual machine exists")
private String domainName;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the name of the domain in which the virtual machine exists")
private String domainName;
@SerializedName(ApiConstants.CREATED) @Param(description="the date when this virtual machine was created")
private Date created;
@SerializedName(ApiConstants.CREATED) @Param(description="the date when this virtual machine was created")
private Date created;
@SerializedName(ApiConstants.STATE) @Param(description="the state of the virtual machine")
private String state;
@SerializedName(ApiConstants.STATE) @Param(description="the state of the virtual machine")
private String state;
@SerializedName(ApiConstants.HA_ENABLE) @Param(description="true if high-availability is enabled, false otherwise")
private Boolean haEnable;
@SerializedName(ApiConstants.HA_ENABLE) @Param(description="true if high-availability is enabled, false otherwise")
private Boolean haEnable;
@SerializedName(ApiConstants.GROUP_ID) @Param(description="the group ID of the virtual machine")
private String groupId;
@SerializedName(ApiConstants.GROUP_ID) @Param(description="the group ID of the virtual machine")
private String groupId;
@SerializedName(ApiConstants.GROUP) @Param(description="the group name of the virtual machine")
private String group;
@SerializedName(ApiConstants.GROUP) @Param(description="the group name of the virtual machine")
private String group;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the availablility zone for the virtual machine")
private String zoneId;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the availablility zone for the virtual machine")
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the availability zone for the virtual machine")
private String zoneName;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the availability zone for the virtual machine")
private String zoneName;
@SerializedName(ApiConstants.HOST_ID) @Param(description="the ID of the host for the virtual machine")
private String hostId;
@SerializedName(ApiConstants.HOST_ID) @Param(description="the ID of the host for the virtual machine")
private String hostId;
@SerializedName("hostname") @Param(description="the name of the host for the virtual machine")
private String hostName;
@SerializedName("hostname") @Param(description="the name of the host for the virtual machine")
private String hostName;
@SerializedName(ApiConstants.TEMPLATE_ID) @Param(description="the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file.")
private String templateId;
@SerializedName(ApiConstants.TEMPLATE_ID) @Param(description="the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file.")
private String templateId;
@SerializedName("templatename") @Param(description="the name of the template for the virtual machine")
private String templateName;
@SerializedName("templatename") @Param(description="the name of the template for the virtual machine")
private String templateName;
@SerializedName("templatedisplaytext") @Param(description=" an alternate display text of the template for the virtual machine")
private String templateDisplayText;
@SerializedName("templatedisplaytext") @Param(description=" an alternate display text of the template for the virtual machine")
private String templateDisplayText;
@SerializedName(ApiConstants.PASSWORD_ENABLED) @Param(description="true if the password rest feature is enabled, false otherwise")
private Boolean passwordEnabled;
@SerializedName(ApiConstants.PASSWORD_ENABLED) @Param(description="true if the password rest feature is enabled, false otherwise")
private Boolean passwordEnabled;
@SerializedName("isoid") @Param(description="the ID of the ISO attached to the virtual machine")
private String isoId;
@SerializedName("isoid") @Param(description="the ID of the ISO attached to the virtual machine")
private String isoId;
@SerializedName("isoname") @Param(description="the name of the ISO attached to the virtual machine")
private String isoName;
@SerializedName("isoname") @Param(description="the name of the ISO attached to the virtual machine")
private String isoName;
@SerializedName("isodisplaytext") @Param(description="an alternate display text of the ISO attached to the virtual machine")
private String isoDisplayText;
@SerializedName("isodisplaytext") @Param(description="an alternate display text of the ISO attached to the virtual machine")
private String isoDisplayText;
@SerializedName(ApiConstants.SERVICE_OFFERING_ID) @Param(description="the ID of the service offering of the virtual machine")
private String serviceOfferingId;
@SerializedName(ApiConstants.SERVICE_OFFERING_ID) @Param(description="the ID of the service offering of the virtual machine")
private String serviceOfferingId;
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
private String serviceOfferingName;
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
private String serviceOfferingName;
@SerializedName("forvirtualnetwork") @Param(description="the virtual network for the service offering")
private Boolean forVirtualNetwork;
@SerializedName("forvirtualnetwork") @Param(description="the virtual network for the service offering")
private Boolean forVirtualNetwork;
@SerializedName(ApiConstants.CPU_NUMBER) @Param(description="the number of cpu this virtual machine is running with")
private Integer cpuNumber;
@SerializedName(ApiConstants.CPU_NUMBER) @Param(description="the number of cpu this virtual machine is running with")
private Integer cpuNumber;
@SerializedName(ApiConstants.CPU_SPEED) @Param(description="the speed of each cpu")
private Integer cpuSpeed;
@SerializedName(ApiConstants.CPU_SPEED) @Param(description="the speed of each cpu")
private Integer cpuSpeed;
@SerializedName(ApiConstants.MEMORY) @Param(description="the memory allocated for the virtual machine")
private Integer memory;
@SerializedName(ApiConstants.MEMORY) @Param(description="the memory allocated for the virtual machine")
private Integer memory;
@SerializedName("cpuused") @Param(description="the amount of the vm's CPU currently used")
private String cpuUsed;
@SerializedName("cpuused") @Param(description="the amount of the vm's CPU currently used")
private String cpuUsed;
@SerializedName("networkkbsread") @Param(description="the incoming network traffic on the vm")
private Long networkKbsRead;
@SerializedName("networkkbsread") @Param(description="the incoming network traffic on the vm")
private Long networkKbsRead;
@SerializedName("networkkbswrite") @Param(description="the outgoing network traffic on the host")
private Long networkKbsWrite;
@SerializedName("networkkbswrite") @Param(description="the outgoing network traffic on the host")
private Long networkKbsWrite;
@SerializedName("diskkbsread") @Param(description="the read (bytes) of disk on the vm")
private Long diskKbsRead;
@SerializedName("diskkbswrite") @Param(description="the write (bytes) of disk on the vm")
private Long diskKbsWrite;
@SerializedName("diskioread") @Param(description="the read (io) of disk on the vm")
private Long diskIORead;
@SerializedName("diskiowrite") @Param(description="the write (io) of disk on the vm")
private Long diskIOWrite;
@SerializedName("guestosid") @Param(description="Os type ID of the virtual machine")
private String guestOsId;
@SerializedName("diskkbsread") @Param(description="the read (bytes) of disk on the vm")
private Long diskKbsRead;
@SerializedName("rootdeviceid") @Param(description="device ID of the root volume")
private Long rootDeviceId;
@SerializedName("diskkbswrite") @Param(description="the write (bytes) of disk on the vm")
private Long diskKbsWrite;
@SerializedName("rootdevicetype") @Param(description="device type of the root volume")
private String rootDeviceType;
@SerializedName("diskioread") @Param(description="the read (io) of disk on the vm")
private Long diskIORead;
@SerializedName("securitygroup") @Param(description="list of security groups associated with the virtual machine", responseObject = SecurityGroupResponse.class)
private Set<SecurityGroupResponse> securityGroupList;
@SerializedName("diskiowrite") @Param(description="the write (io) of disk on the vm")
private Long diskIOWrite;
@SerializedName(ApiConstants.PASSWORD) @Param(description="the password (if exists) of the virtual machine")
private String password;
@SerializedName("guestosid") @Param(description="Os type ID of the virtual machine")
private String guestOsId;
@SerializedName("nic") @Param(description="the list of nics associated with vm", responseObject = NicResponse.class)
private Set<NicResponse> nics;
@SerializedName("rootdeviceid") @Param(description="device ID of the root volume")
private Long rootDeviceId;
@SerializedName("hypervisor") @Param(description="the hypervisor on which the template runs")
private String hypervisor;
@SerializedName("rootdevicetype") @Param(description="device type of the root volume")
private String rootDeviceType;
@SerializedName(ApiConstants.PUBLIC_IP_ID) @Param(description="public IP address id associated with vm via Static nat rule")
private String publicIpId;
@SerializedName("securitygroup") @Param(description="list of security groups associated with the virtual machine", responseObject = SecurityGroupResponse.class)
private Set<SecurityGroupResponse> securityGroupList;
@SerializedName(ApiConstants.PUBLIC_IP) @Param(description="public IP address id associated with vm via Static nat rule")
private String publicIp;
@SerializedName(ApiConstants.PASSWORD) @Param(description="the password (if exists) of the virtual machine")
private String password;
@SerializedName(ApiConstants.INSTANCE_NAME) @Param(description="instance name of the user vm; this parameter is returned to the ROOT admin only", since="3.0.1")
private String instanceName;
@SerializedName("nic") @Param(description="the list of nics associated with vm", responseObject = NicResponse.class)
private Set<NicResponse> nics;
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with vm", responseObject = ResourceTagResponse.class)
private Set<ResourceTagResponse> tags;
@SerializedName("hypervisor") @Param(description="the hypervisor on which the template runs")
private String hypervisor;
@SerializedName(ApiConstants.SSH_KEYPAIR) @Param(description="ssh key-pair")
private String keyPairName;
@SerializedName(ApiConstants.PUBLIC_IP_ID) @Param(description="public IP address id associated with vm via Static nat rule")
private String publicIpId;
@SerializedName("affinitygroup")
@Param(description = "list of affinity groups associated with the virtual machine", responseObject = AffinityGroupResponse.class)
private Set<AffinityGroupResponse> affinityGroupList;
@SerializedName(ApiConstants.PUBLIC_IP) @Param(description="public IP address id associated with vm via Static nat rule")
private String publicIp;
@SerializedName(ApiConstants.DISPLAY_VM) @Param(description="an optional field whether to the display the vm to the end user or not.")
private Boolean displayVm;
@SerializedName(ApiConstants.INSTANCE_NAME) @Param(description="instance name of the user vm; this parameter is returned to the ROOT admin only", since="3.0.1")
private String instanceName;
@SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @Param(description="true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
private Boolean isDynamicallyScalable;
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with vm", responseObject = ResourceTagResponse.class)
private Set<ResourceTagResponse> tags;
public UserVmResponse(){
securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
nics = new LinkedHashSet<NicResponse>();
tags = new LinkedHashSet<ResourceTagResponse>();
affinityGroupList = new LinkedHashSet<AffinityGroupResponse>();
}
@SerializedName(ApiConstants.SSH_KEYPAIR) @Param(description="ssh key-pair")
private String keyPairName;
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}
@SerializedName("affinitygroup")
@Param(description = "list of affinity groups associated with the virtual machine", responseObject = AffinityGroupResponse.class)
private Set<AffinityGroupResponse> affinityGroupList;
public void setId(String id) {
this.id = id;
}
@SerializedName(ApiConstants.DISPLAY_VM) @Param(description="an optional field whether to the display the vm to the end user or not.")
private Boolean displayVm;
public String getId() {
return this.id;
}
@SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @Param(description="true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
private Boolean isDynamicallyScalable;
@SerializedName(ApiConstants.SERVICE_STATE) @Param(description="State of the Service from LB rule")
private String serviceState;
public Boolean getDisplayVm() {
return displayVm;
}
public UserVmResponse(){
securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
nics = new LinkedHashSet<NicResponse>();
tags = new LinkedHashSet<ResourceTagResponse>();
affinityGroupList = new LinkedHashSet<AffinityGroupResponse>();
}
public void setDisplayVm(Boolean displayVm) {
this.displayVm = displayVm;
}
@Override
public String getObjectId() {
return this.getId();
}
public void setName(String name) {
this.name = name;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
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;
}
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}
public void setCreated(Date created) {
this.created = created;
}
public void setId(String id) {
this.id = id;
}
public void setState(String state) {
this.state = state;
}
public String getId() {
return this.id;
}
public void setHaEnable(Boolean haEnable) {
this.haEnable = haEnable;
}
public Boolean getDisplayVm() {
return displayVm;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public void setDisplayVm(Boolean displayVm) {
this.displayVm = displayVm;
}
public void setGroup(String group) {
this.group = group;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setHostId(String hostId) {
this.hostId = hostId;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public void setTemplateDisplayText(String templateDisplayText) {
this.templateDisplayText = templateDisplayText;
}
public void setPasswordEnabled(Boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public void setIsoId(String isoId) {
this.isoId = isoId;
}
public void setIsoName(String isoName) {
this.isoName = isoName;
}
public void setIsoDisplayText(String isoDisplayText) {
this.isoDisplayText = isoDisplayText;
}
public void setDiskKbsRead(Long diskKbsRead) {
this.diskKbsRead = diskKbsRead;
}
public void setDiskKbsWrite(Long diskKbsWrite) {
this.diskKbsWrite = diskKbsWrite;
}
public void setDiskIORead(Long diskIORead) {
this.diskIORead = diskIORead;
}
public void setDiskIOWrite(Long diskIOWrite) {
this.diskIOWrite = diskIOWrite;
}
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public void setCpuNumber(Integer cpuNumber) {
this.cpuNumber = cpuNumber;
}
public void setCpuSpeed(Integer cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public void setMemory(Integer memory) {
this.memory = memory;
}
public void setCpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
}
public void setNetworkKbsRead(Long networkKbsRead) {
this.networkKbsRead = networkKbsRead;
}
public void setNetworkKbsWrite(Long networkKbsWrite) {
this.networkKbsWrite = networkKbsWrite;
}
public void setGuestOsId(String guestOsId) {
this.guestOsId = guestOsId;
}
public void setRootDeviceId(Long rootDeviceId) {
this.rootDeviceId = rootDeviceId;
}
public void setRootDeviceType(String rootDeviceType) {
this.rootDeviceType = rootDeviceType;
}
public void setPassword(String password) {
this.password = password;
}
public void setForVirtualNetwork(Boolean forVirtualNetwork) {
this.forVirtualNetwork = forVirtualNetwork;
}
public void setNics(Set<NicResponse> nics) {
this.nics = nics;
}
public void addNic(NicResponse nic) {
this.nics.add(nic);
}
public void setSecurityGroupList(Set<SecurityGroupResponse> securityGroups) {
this.securityGroupList = securityGroups;
}
public void addSecurityGroup(SecurityGroupResponse securityGroup){
this.securityGroupList.add(securityGroup);
}
@Override
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setPublicIpId(String publicIpId) {
this.publicIpId = publicIpId;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
public void setTags(Set<ResourceTagResponse> tags) {
this.tags = tags;
}
public void addTag(ResourceTagResponse tag){
this.tags.add(tag);
}
public void setKeyPairName(String keyPairName) {
this.keyPairName = keyPairName;
}
public void setAffinityGroupList(Set<AffinityGroupResponse> affinityGroups) {
this.affinityGroupList = affinityGroups;
}
public void addAffinityGroup(AffinityGroupResponse affinityGroup) {
this.affinityGroupList.add(affinityGroup);
}
public void setDynamicallyScalable(boolean isDynamicallyScalable) {
this.isDynamicallyScalable = isDynamicallyScalable;
}
@Override
public String getObjectId() {
return this.getId();
}
public String getName() {
return name;
}
public String getDisplayName() {
return displayName;
}
public String getAccountName() {
return accountName;
}
public String getProjectId() {
return projectId;
}
public String getProjectName() {
return projectName;
}
public String getDomainId() {
return domainId;
}
public String getDomainName() {
return domainName;
}
public Date getCreated() {
return created;
}
public String getState() {
return state;
}
public Boolean getHaEnable() {
return haEnable;
}
public String getGroupId() {
return groupId;
}
public String getGroup() {
return group;
}
public String getZoneId() {
return zoneId;
}
public String getZoneName() {
return zoneName;
}
public String getHostId() {
return hostId;
}
public String getHostName() {
return hostName;
}
public String getTemplateId() {
return templateId;
}
public String getTemplateName() {
return templateName;
}
public String getTemplateDisplayText() {
return templateDisplayText;
}
public Boolean getPasswordEnabled() {
return passwordEnabled;
}
public String getIsoId() {
return isoId;
}
public String getIsoName() {
return isoName;
}
public String getIsoDisplayText() {
return isoDisplayText;
}
public String getServiceOfferingId() {
return serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public Boolean getForVirtualNetwork() {
return forVirtualNetwork;
}
public Integer getCpuNumber() {
return cpuNumber;
}
public Integer getCpuSpeed() {
return cpuSpeed;
}
public Integer getMemory() {
return memory;
}
public String getCpuUsed() {
return cpuUsed;
}
public Long getNetworkKbsRead() {
return networkKbsRead;
}
public Long getNetworkKbsWrite() {
return networkKbsWrite;
}
public Long getDiskKbsRead() {
return diskKbsRead;
}
public Long getDiskKbsWrite() {
return diskKbsWrite;
}
public Long getDiskIORead() {
return diskIORead;
}
public Long getDiskIOWrite() {
return diskIOWrite;
}
public String getGuestOsId() {
return guestOsId;
}
public Long getRootDeviceId() {
return rootDeviceId;
}
public String getRootDeviceType() {
return rootDeviceType;
}
public Set<SecurityGroupResponse> getSecurityGroupList() {
return securityGroupList;
}
public String getPassword() {
return password;
}
public Set<NicResponse> getNics() {
return nics;
}
public String getHypervisor() {
return hypervisor;
}
public String getPublicIpId() {
return publicIpId;
}
public String getPublicIp() {
return publicIp;
}
public String getInstanceName() {
return instanceName;
}
public Set<ResourceTagResponse> getTags() {
return tags;
}
public String getKeyPairName() {
return keyPairName;
}
public Set<AffinityGroupResponse> getAffinityGroupList() {
return affinityGroupList;
}
public Boolean getIsDynamicallyScalable() {
return isDynamicallyScalable;
}
public String getServiceState() {
return serviceState;
}
public void setIsDynamicallyScalable(Boolean isDynamicallyScalable) {
this.isDynamicallyScalable = isDynamicallyScalable;
}
public void setName(String name) {
this.name = name;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Override
public void setAccountName(String accountName) {
this.accountName = accountName;
}
@Override
public void setDomainId(String domainId) {
this.domainId = domainId;
}
@Override
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public void setCreated(Date created) {
this.created = created;
}
public void setState(String state) {
this.state = state;
}
public void setHaEnable(Boolean haEnable) {
this.haEnable = haEnable;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public void setGroup(String group) {
this.group = group;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setHostId(String hostId) {
this.hostId = hostId;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public void setTemplateDisplayText(String templateDisplayText) {
this.templateDisplayText = templateDisplayText;
}
public void setPasswordEnabled(Boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public void setIsoId(String isoId) {
this.isoId = isoId;
}
public void setIsoName(String isoName) {
this.isoName = isoName;
}
public void setIsoDisplayText(String isoDisplayText) {
this.isoDisplayText = isoDisplayText;
}
public void setDiskKbsRead(Long diskKbsRead) {
this.diskKbsRead = diskKbsRead;
}
public void setDiskKbsWrite(Long diskKbsWrite) {
this.diskKbsWrite = diskKbsWrite;
}
public void setDiskIORead(Long diskIORead) {
this.diskIORead = diskIORead;
}
public void setDiskIOWrite(Long diskIOWrite) {
this.diskIOWrite = diskIOWrite;
}
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public void setCpuNumber(Integer cpuNumber) {
this.cpuNumber = cpuNumber;
}
public void setCpuSpeed(Integer cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
public void setMemory(Integer memory) {
this.memory = memory;
}
public void setCpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
}
public void setNetworkKbsRead(Long networkKbsRead) {
this.networkKbsRead = networkKbsRead;
}
public void setNetworkKbsWrite(Long networkKbsWrite) {
this.networkKbsWrite = networkKbsWrite;
}
public void setGuestOsId(String guestOsId) {
this.guestOsId = guestOsId;
}
public void setRootDeviceId(Long rootDeviceId) {
this.rootDeviceId = rootDeviceId;
}
public void setRootDeviceType(String rootDeviceType) {
this.rootDeviceType = rootDeviceType;
}
public void setPassword(String password) {
this.password = password;
}
public void setForVirtualNetwork(Boolean forVirtualNetwork) {
this.forVirtualNetwork = forVirtualNetwork;
}
public void setNics(Set<NicResponse> nics) {
this.nics = nics;
}
public void addNic(NicResponse nic) {
this.nics.add(nic);
}
public void setSecurityGroupList(Set<SecurityGroupResponse> securityGroups) {
this.securityGroupList = securityGroups;
}
public void addSecurityGroup(SecurityGroupResponse securityGroup){
this.securityGroupList.add(securityGroup);
}
@Override
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setPublicIpId(String publicIpId) {
this.publicIpId = publicIpId;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
public void setTags(Set<ResourceTagResponse> tags) {
this.tags = tags;
}
public void addTag(ResourceTagResponse tag){
this.tags.add(tag);
}
public void setKeyPairName(String keyPairName) {
this.keyPairName = keyPairName;
}
public void setAffinityGroupList(Set<AffinityGroupResponse> affinityGroups) {
this.affinityGroupList = affinityGroups;
}
public void addAffinityGroup(AffinityGroupResponse affinityGroup) {
this.affinityGroupList.add(affinityGroup);
}
public void setDynamicallyScalable(boolean isDynamicallyScalable) {
this.isDynamicallyScalable = isDynamicallyScalable;
}
public void setServiceState(String state) {
this.serviceState = state;
}
}

View File

@ -0,0 +1,84 @@
// 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.config;
import java.util.Date;
/**
* Configuration represents one global configuration parameter for CloudStack.
* Its scope should indicate whether this parameter can be set at different
* organization levels in CloudStack.
*
*/
public interface Configuration {
/**
* @return Category of the parameter.
*/
String getCategory();
/**
* @return Server instance that uses this parameter.
*/
String getInstance();
/**
* @return Component that introduced this parameter.
*/
String getComponent();
/**
* @return Name of the parameter.
*/
String getName();
/**
* @return Value set by the administrator. Defaults to the defaultValue.
*/
String getValue();
/**
* @return Description of the value and the range of the value.
*/
String getDescription();
/**
* @return Default value for this parameter. Null indicates this parameter is optional.
*/
String getDefaultValue();
/**
* @return Scope for the parameter. Null indicates that this parameter is
* always global. A non-null value indicates that this parameter can be
* set at a certain organization level.
*/
String getScope();
/**
* @return can the configuration parameter be changed without restarting the server.
*/
boolean isDynamic();
/**
* @return The date this VO was updated by the components. Note that this is not
* a date for when an administrator updates the value. This is when the system
* updated this value. By searching on this field gives you all the config
* parameters that have changed in an upgrade. Null value indicates that this
* parameter is no longer used and can be deleted.
*/
Date getUpdated();
}

View File

@ -14,15 +14,37 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.async;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
package org.apache.cloudstack.jobs;
import java.util.Date;
public interface AsyncJob extends Identity, InternalIdentity {
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface JobInfo extends Identity, InternalIdentity {
public enum Status {
IN_PROGRESS(false),
SUCCEEDED(true),
FAILED(true),
CANCELLED(true);
private final boolean done;
private Status(boolean done) {
this.done = done;
}
public boolean done() {
return done;
}
}
String getType();
String getDispatcher();
int getPendingSignals();
long getUserId();
long getAccountId();
@ -33,11 +55,7 @@ public interface AsyncJob extends Identity, InternalIdentity {
String getCmdInfo();
int getCallbackType();
String getCallbackAddress();
int getStatus();
Status getStatus();
int getProcessStatus();
@ -47,6 +65,8 @@ public interface AsyncJob extends Identity, InternalIdentity {
Long getInitMsid();
Long getExecutingMsid();
Long getCompleteMsid();
Date getCreated();
@ -55,17 +75,7 @@ public interface AsyncJob extends Identity, InternalIdentity {
Date getLastPolled();
Date getRemoved();
ApiCommandJobType getInstanceType();
String getInstanceType();
Long getInstanceId();
String getSessionKey();
String getCmdOriginator();
boolean isFromPreviousSession();
SyncQueueItem getSyncSource();
}

View File

@ -20,7 +20,7 @@ import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
import org.apache.cloudstack.api.command.admin.storage.ListCacheStoresCmd;
import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd;
import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd;
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
@ -81,7 +81,7 @@ public interface QueryService {
public ListResponse<ImageStoreResponse> searchForImageStores(ListImageStoresCmd cmd);
public ListResponse<ImageStoreResponse> searchForCacheStores(ListCacheStoresCmd cmd);
public ListResponse<ImageStoreResponse> searchForSecondaryStagingStores(ListSecondaryStagingStoresCmd cmd);
public ListResponse<AccountResponse> searchForAccounts(ListAccountsCmd cmd);

View File

@ -31,10 +31,11 @@ public interface Region {
public void setName(String name);
public String getEndPoint();
public boolean checkIfServiceEnabled(Service service);
public void enableService(Service service);
/**
* A region level service, is a service that constitute services across one or more zones in the region or a service
* made available to all the zones in the region.
@ -45,6 +46,7 @@ public interface Region {
private static List<Service> regionServices = new ArrayList<Service>();
public static final Service Gslb = new Service("Gslb");
public static final Service PortableIp = new Service("PortableIp");
public Service(String name ) {
this.name = name;

View File

@ -16,19 +16,8 @@
// under the License.
package org.apache.cloudstack.usage;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
public interface Usage {
public long getId();
@ -39,7 +28,7 @@ public interface Usage {
public Long getDomainId();
public String getDescription();
public String getDescription();
public String getUsageDisplay();

View File

@ -40,6 +40,7 @@ public class UsageTypes {
public static final int VM_DISK_IO_WRITE = 22;
public static final int VM_DISK_BYTES_READ = 23;
public static final int VM_DISK_BYTES_WRITE = 24;
public static final int VM_SNAPSHOT = 25;
public static List<UsageTypeResponse> listUsageTypes(){
List<UsageTypeResponse> responseList = new ArrayList<UsageTypeResponse>();
@ -61,6 +62,7 @@ public class UsageTypes {
responseList.add(new UsageTypeResponse(VM_DISK_IO_WRITE, "VM Disk usage(I/O Write)"));
responseList.add(new UsageTypeResponse(VM_DISK_BYTES_READ, "VM Disk usage(Bytes Read)"));
responseList.add(new UsageTypeResponse(VM_DISK_BYTES_WRITE, "VM Disk usage(Bytes Write)"));
responseList.add(new UsageTypeResponse(VM_SNAPSHOT, "VM Snapshot storage usage"));
return responseList;
}
}

View File

@ -23,6 +23,7 @@ import org.junit.Before;
import org.junit.Test;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.IsolationType;
/**
* @author dhoogland
@ -45,7 +46,8 @@ public class NetworksTest {
@Test
public void vlanBroadcastDomainTypeTest() throws URISyntaxException {
String uri1 = "vlan://1";
String uri2 = "vlan:2";
Long value2 = 2L;
String uri2 = BroadcastDomainType.Vlan.toUri(value2).toString();
BroadcastDomainType type1 = BroadcastDomainType.getTypeOf(uri1);
BroadcastDomainType type2 = BroadcastDomainType.getTypeOf(uri2);
String id1 = BroadcastDomainType.getValue(uri1);
@ -55,20 +57,29 @@ public class NetworksTest {
Assert.assertEquals("uri2 should be of broadcasttype vlan",
BroadcastDomainType.Vlan, type2);
Assert.assertEquals("id1 should be \"1\"", "1", id1);
Assert.assertEquals("id1 should be \"2\"", "2", id2);
Assert.assertEquals("id2 should be \"2\"", "2", id2);
}
@Test
public void vlanIsolationTypeTest() throws URISyntaxException {
String uri1 = "vlan://1";
Long value2 = 2L;
String uri2 = IsolationType.Vlan.toUri(value2).toString();
Assert.assertEquals("id1 should be \"vlan://1\"", "vlan://1", uri1);
Assert.assertEquals("id2 should be \"vlan://2\"", "vlan://2", uri2);
}
@Test
public void otherTypesTest() throws URISyntaxException {
String bogeyUri = "lswitch://1";
String uri2 = "mido:2";
String uri2 = "mido://2";
BroadcastDomainType type1 = BroadcastDomainType.getTypeOf(bogeyUri);
BroadcastDomainType type2 = BroadcastDomainType.getTypeOf(uri2);
String id1 = BroadcastDomainType.getValue(bogeyUri);
String id2 = BroadcastDomainType.getValue(uri2);
Assert.assertEquals("uri1 should be of broadcasttype vlan",
Assert.assertEquals("uri1 should be of broadcasttype lswitch",
BroadcastDomainType.Lswitch, type1);
Assert.assertEquals("uri2 should be of broadcasttype vlan",
Assert.assertEquals("uri2 should be of broadcasttype mido",
BroadcastDomainType.Mido, type2);
Assert.assertEquals("id1 should be \"//1\"", "//1", id1);
Assert.assertEquals("id1 should be \"2\"", "2", id2);

View File

@ -16,25 +16,26 @@
// under the License.
package org.apache.cloudstack.api.command.test;
import java.util.Arrays;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.org.Cluster;
import com.cloud.resource.ResourceService;
import edu.emory.mathcs.backport.java.util.Arrays;
public class AddClusterCmdTest extends TestCase {
private AddClusterCmd addClusterCmd;
@ -44,6 +45,7 @@ public class AddClusterCmdTest extends TestCase {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
@Before
public void setUp() {
/*
@ -110,8 +112,7 @@ public class AddClusterCmdTest extends TestCase {
Cluster cluster = Mockito.mock(Cluster.class);
Cluster[] clusterArray = new Cluster[] { cluster };
Mockito.when(resourceService.discoverCluster(addClusterCmd))
.thenReturn(Arrays.asList(clusterArray));
Mockito.doReturn(Arrays.asList(clusterArray)).when(resourceService).discoverCluster(addClusterCmd);
addClusterCmd.execute();

View File

@ -16,27 +16,28 @@
// under the License.
package org.apache.cloudstack.api.command.test;
import java.util.Arrays;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.host.Host;
import com.cloud.resource.ResourceService;
import edu.emory.mathcs.backport.java.util.Arrays;
public class AddHostCmdTest extends TestCase {
private AddHostCmd addHostCmd;
@ -46,6 +47,7 @@ public class AddHostCmdTest extends TestCase {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
@Before
public void setUp() {
resourceService = Mockito.mock(ResourceService.class);
@ -125,14 +127,12 @@ public class AddHostCmdTest extends TestCase {
HostResponse responseHost = new HostResponse();
responseHost.setName("Test");
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(
Arrays.asList(mockArray));
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(
responseHost);
Mockito.doReturn(Arrays.asList(mockArray)).when(resourceService).discoverHosts(addHostCmd);
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(responseHost);
addHostCmd.execute();
Mockito.verify(responseGenerator).createHostResponse(host);
ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>) addHostCmd
.getResponseObject());
@SuppressWarnings("unchecked")
ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
@ -144,8 +144,7 @@ public class AddHostCmdTest extends TestCase {
addHostCmd._resourceService = resourceService;
try {
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenThrow(
DiscoveryException.class);
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenThrow(DiscoveryException.class);
} catch (InvalidParameterValueException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {

View File

@ -16,19 +16,22 @@
// under the License.
package org.apache.cloudstack.api.command.test;
import com.cloud.configuration.Configuration;
import com.cloud.configuration.ConfigurationService;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.resource.ResourceService;
import com.cloud.server.ManagementService;
import com.cloud.utils.Pair;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
import org.apache.cloudstack.api.response.ConfigurationResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.config.Configuration;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

View File

@ -24,16 +24,12 @@ import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import static org.mockito.Matchers.anyInt;
import java.util.LinkedList;
import java.util.List;
@ -45,6 +41,7 @@ public class ScaleVMCmdTest extends TestCase{
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
@Before
public void setUp() {

View File

@ -16,16 +16,19 @@
// under the License.
package org.apache.cloudstack.api.command.test;
import com.cloud.configuration.Configuration;
import com.cloud.configuration.ConfigurationService;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.resource.ResourceService;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
import org.apache.cloudstack.api.response.ConfigurationResponse;
import org.apache.cloudstack.config.Configuration;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

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