Merge branch 'master' into ui-multiple-vlan-ranges

This commit is contained in:
Brian Federle 2013-03-13 15:21:37 -07:00
commit a9b1d1d73e
1039 changed files with 38727 additions and 27725 deletions

27
LICENSE
View File

@ -370,7 +370,7 @@ Within the scripts/vm/hypervisor/xenserver directory
from OpenStack, LLC http://www.openstack.org
swift
Within the tools/appliance/definitions/systemvmtemplate directory
Within the tools/appliance/definitions/systemvmtemplate and tools/appliance/definitions/systemvmtemplate64 directory
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Copyright (c) 2010-2012 Patrick Debois
@ -471,6 +471,31 @@ Within the ui/lib directory
from George McGinley Smith
jquery.easing.js
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from The Dojo Foundation http://dojofoundation.org/
require.js from http://github.com/jrburke/requirejs
licensed under the MIT License http://www.opensource.org/licenses/mit-license.php (as follows)
Copyright (c) 2011, John Resig

View File

@ -79,4 +79,4 @@ domr.scripts.dir=scripts/network/domr/kvm
# be overridden here.
# native = com.cloud.hypervisor.kvm.resource.BridgeVifDriver
# openvswitch = com.cloud.hypervisor.kvm.resource.OvsBridgeDriver
#libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver
#libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver

View File

@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.2.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
@ -35,8 +35,6 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-utils</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -83,7 +81,7 @@
<filterreader
classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile"
value="${basedir}/../build/replace.properties" />
value="${cs.replace.properties}" />
</filterreader>
</filterchain>
</copy>
@ -97,7 +95,7 @@
<filterreader
classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile"
value="${basedir}/../build/replace.properties" />
value="${cs.replace.properties}" />
</filterreader>
</filterchain>
</copy>
@ -106,6 +104,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -38,16 +38,20 @@ import java.util.UUID;
import javax.naming.ConfigurationException;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import com.cloud.agent.Agent.ExitStatus;
import com.cloud.agent.dao.StorageComponent;
import com.cloud.agent.dao.impl.PropertiesStorage;
import com.cloud.host.Host;
import com.cloud.resource.ServerResource;
import com.cloud.utils.LogUtils;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.ProcessUtil;
import com.cloud.utils.PropertiesUtil;
@ -376,6 +380,18 @@ public class AgentShell implements IAgentShell {
public void init(String[] args) throws ConfigurationException {
// PropertiesUtil is used both in management server and agent packages,
// it searches path under class path and common J2EE containers
// For KVM agent, do it specially here
File file = new File("/etc/cloudstack/agent/log4j-cloud.xml");
if(file == null || !file.exists()) {
file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
}
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
s_logger.info("Agent started");
final Class<?> c = this.getClass();
_version = c.getPackage().getImplementationVersion();
if (_version == null) {
@ -552,6 +568,9 @@ public class AgentShell implements IAgentShell {
public void start() {
try {
/* By default we only search for log4j.xml */
LogUtils.initLog4j("log4j-cloud.xml");
System.setProperty("java.net.preferIPv4Stack", "true");
String instance = getProperty(null, "instance");

View File

@ -26,6 +26,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@ -77,7 +78,7 @@ import com.google.gson.Gson;
* server.
*
*/
public abstract class ConsoleProxyResource extends ServerResourceBase implements
public class ConsoleProxyResource extends ServerResourceBase implements
ServerResource {
static final Logger s_logger = Logger.getLogger(ConsoleProxyResource.class);
@ -489,4 +490,26 @@ public abstract class ConsoleProxyResource extends ServerResourceBase implements
}
}
}
@Override
public void setName(String name) {
}
@Override
public void setConfigParams(Map<String, Object> params) {
}
@Override
public Map<String, Object> getConfigParams() {
return new HashMap<String, Object>();
}
@Override
public int getRunLevel() {
return 0;
}
@Override
public void setRunLevel(int level) {
}
}

View File

@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.2.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>

View File

@ -18,6 +18,7 @@ package com.cloud.agent.api;
import com.cloud.storage.StoragePool;
/**
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
*/

View File

@ -14,11 +14,15 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.region.dao;
package com.cloud.agent.api;
import org.apache.cloudstack.region.RegionSyncVO;
public class ScaleVmAnswer extends Answer {
import com.cloud.utils.db.GenericDao;
protected ScaleVmAnswer() {
}
public ScaleVmAnswer(ScaleVmCommand cmd, boolean result, String detail) {
super(cmd, result, detail);
}
public interface RegionSyncDao extends GenericDao<RegionSyncVO, Integer> {
}

View File

@ -0,0 +1,113 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api;
import com.cloud.agent.api.to.VirtualMachineTO;
public class ScaleVmCommand extends Command {
VirtualMachineTO vm;
String vmName;
int cpus;
Integer speed;
long minRam;
long maxRam;
public VirtualMachineTO getVm() {
return vm;
}
public void setVm(VirtualMachineTO vm) {
this.vm = vm;
}
public int getCpus() {
return cpus;
}
public ScaleVmCommand(String vmName, int cpus,
Integer speed, long minRam, long maxRam) {
super();
this.vmName = vmName;
this.cpus = cpus;
//this.speed = speed;
this.minRam = minRam;
this.maxRam = maxRam;
this.vm = new VirtualMachineTO(1L, vmName, null, cpus, null, minRam, maxRam, null, null, false, false, null);
/*vm.setName(vmName);
vm.setCpus(cpus);
vm.setRam(minRam, maxRam);*/
}
public void setCpus(int cpus) {
this.cpus = cpus;
}
public Integer getSpeed() {
return speed;
}
public void setSpeed(Integer speed) {
this.speed = speed;
}
public long getMinRam() {
return minRam;
}
public void setMinRam(long minRam) {
this.minRam = minRam;
}
public long getMaxRam() {
return maxRam;
}
public void setMaxRam(long maxRam) {
this.maxRam = maxRam;
}
public String getVmName() {
return vmName;
}
public void setVmName(String vmName) {
this.vmName = vmName;
}
public VirtualMachineTO getVirtualMachine() {
return vm;
}
@Override
public boolean executeInSequence() {
return true;
}
protected ScaleVmCommand() {
}
public ScaleVmCommand(VirtualMachineTO vm) {
this.vm = vm;
}
public boolean getLimitCpuUse() {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -18,6 +18,7 @@ package com.cloud.agent.api;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.zip.DeflaterOutputStream;
import org.apache.commons.codec.binary.Base64;
@ -80,6 +81,7 @@ public class SecurityGroupRulesCmd extends Command {
Long msId;
IpPortAndProto [] ingressRuleSet;
IpPortAndProto [] egressRuleSet;
private List<String> secIps;
public SecurityGroupRulesCmd() {
super();
@ -103,6 +105,23 @@ public class SecurityGroupRulesCmd extends Command {
}
public SecurityGroupRulesCmd(String guestIp, String guestMac, String vmName, Long vmId, String signature, Long seqNum, IpPortAndProto[] ingressRuleSet, IpPortAndProto[] egressRuleSet, List<String> secIps) {
super();
this.guestIp = guestIp;
this.vmName = vmName;
this.ingressRuleSet = ingressRuleSet;
this.egressRuleSet = egressRuleSet;
this.guestMac = guestMac;
this.signature = signature;
this.seqNum = seqNum;
this.vmId = vmId;
if (signature == null) {
String stringified = stringifyRules();
this.signature = DigestUtils.md5Hex(stringified);
}
this.secIps = secIps;
}
@Override
public boolean executeInSequence() {
return true;
@ -131,6 +150,10 @@ public class SecurityGroupRulesCmd extends Command {
return guestIp;
}
public List<String> getSecIps() {
return secIps;
}
public String getVmName() {
return vmName;
@ -165,6 +188,20 @@ public class SecurityGroupRulesCmd extends Command {
}
public String getSecIpsString() {
StringBuilder sb = new StringBuilder();
List<String> ips = getSecIps();
if (ips == null) {
return "0:";
} else {
for (String ip : ips) {
sb.append(ip).append(":");
}
}
return sb.toString();
}
public String stringifyCompressedRules() {
StringBuilder ruleBuilder = new StringBuilder();
for (SecurityGroupRulesCmd.IpPortAndProto ipPandP : getIngressRuleSet()) {

View File

@ -31,6 +31,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
String vmIp6Address;
String ip6Gateway;
String duid;
private boolean isDefault;
protected DhcpEntryCommand() {
@ -46,6 +47,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
this.vmIpAddress = vmIpAddress;
this.vmName = vmName;
this.vmIp6Address = vmIp6Address;
this.setDefault(true);
}
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address, String dns, String gateway, String ip6Gateway) {
@ -129,4 +131,12 @@ public class DhcpEntryCommand extends NetworkElementCommand {
public void setVmIp6Address(String ip6Address) {
this.vmIp6Address = ip6Address;
}
public boolean isDefault() {
return isDefault;
}
public void setDefault(boolean isDefault) {
this.isDefault = isDefault;
}
}

View File

@ -16,12 +16,15 @@
// under the License.
package com.cloud.agent.api.to;
import java.util.List;
public class NicTO extends NetworkTO {
int deviceId;
Integer networkRateMbps;
Integer networkRateMulticastMbps;
boolean defaultNic;
String uuid;
List <String> nicSecIps;
public NicTO() {
super();
@ -69,4 +72,12 @@ public class NicTO extends NetworkTO {
public String toString() {
return new StringBuilder("[Nic:").append(type).append("-").append(ip).append("-").append(broadcastUri).append("]").toString();
}
public void setNicSecIps(List<String> secIps) {
this.nicSecIps = secIps;
}
public List<String> getNicSecIps() {
return nicSecIps;
}
}

View File

@ -28,7 +28,20 @@ public class VirtualMachineTO {
private BootloaderType bootloader;
Type type;
int cpus;
/**
'speed' is still here since 4.0.X/4.1.X management servers do not support
the overcommit feature yet.
The overcommit feature sends minSpeed and maxSpeed
So this is here for backwards compatibility with 4.0.X/4.1.X management servers
and newer agents.
*/
Integer speed;
Integer minSpeed;
Integer maxSpeed;
long minRam;
long maxRam;
String hostName;
@ -62,6 +75,22 @@ public class VirtualMachineTO {
this.vncPassword = vncPassword;
}
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer minSpeed, Integer maxSpeed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
this.id = id;
this.name = instanceName;
this.type = type;
this.cpus = cpus;
this.minSpeed = minSpeed;
this.maxSpeed = maxSpeed;
this.minRam = minRam;
this.maxRam = maxRam;
this.bootloader = bootloader;
this.os = os;
this.enableHA = enableHA;
this.limitCpuUse = limitCpuUse;
this.vncPassword = vncPassword;
}
protected VirtualMachineTO() {
}
@ -105,6 +134,13 @@ public class VirtualMachineTO {
return speed;
}
public Integer getMinSpeed() {
return minSpeed;
}
public Integer getMaxSpeed() {
return maxSpeed;
}
public boolean getLimitCpuUse() {
return limitCpuUse;
}

View File

@ -30,4 +30,5 @@ public interface Alert extends Identity, InternalIdentity {
Date getCreatedDate();
Date getLastSent();
Date getResolved();
boolean getArchived();
}

View File

@ -264,6 +264,8 @@ public interface ConfigurationService {
boolean removeLDAP(LDAPRemoveCmd cmd);
LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
/**
* @param offering
* @return

View File

@ -37,6 +37,10 @@ public interface DataCenter extends InfrastructureEntity, Grouping, Identity, In
String getDns2();
String getIp6Dns1();
String getIp6Dns2();
String getGuestNetworkCidr();
String getName();

View File

@ -40,4 +40,5 @@ public interface Event extends ControlledEntity, Identity, InternalIdentity {
String getLevel();
long getStartId();
String getParameters();
boolean getArchived();
}

View File

@ -32,6 +32,10 @@ public class PermissionDeniedException extends CloudRuntimeException {
super(message);
}
public PermissionDeniedException(String message, Throwable cause){
super(message, cause);
}
protected PermissionDeniedException() {
super();
}

View File

@ -17,14 +17,12 @@
package com.cloud.exception;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Exception thrown if number of requests is over api rate limit set.
* @author minc
*
*/
public class RequestLimitException extends CloudRuntimeException {
public class RequestLimitException extends PermissionDeniedException {
private static final long serialVersionUID = SerialVersionUID.AccountLimitException;

View File

@ -46,4 +46,10 @@ public interface HypervisorCapabilities extends Identity, InternalIdentity{
* @return the max. data volumes per VM supported by hypervisor
*/
Integer getMaxDataVolumesLimit();
/**
* @return the max. hosts per cluster supported by hypervisor
*/
Integer getMaxHostsPerCluster();
}

View File

@ -87,4 +87,7 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity
* @param vpcId
*/
void setVpcId(Long vpcId);
String getVmIp();
void setVmIp(String vmIp);
}

View File

@ -283,12 +283,21 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
String getGateway();
// "cidr" is the Cloudstack managed address space, all CloudStack managed vms get IP address from "cidr",
// In general "cidr" also serves as the network CIDR
// But in case IP reservation is configured for a Guest network, "networkcidr" is the Effective network CIDR for that network,
// "cidr" will still continue to be the effective address space for CloudStack managed vms in that Guest network
String getCidr();
// "networkcidr" is the network CIDR of the guest network which uses IP reservation.
// It is the summation of "cidr" and the reservedIPrange(the address space used for non CloudStack purposes).
// For networks not configured with IP reservation, "networkcidr" is always null
String getNetworkCidr();
String getIp6Gateway();
String getIp6Cidr();
long getDataCenterId();
long getNetworkOfferingId();

View File

@ -255,4 +255,6 @@ public interface NetworkModel {
boolean isIP6AddressAvailableInVlan(long vlanId);
void checkIp6Parameters(String startIPv6, String endIPv6, String ip6Gateway, String ip6Cidr) throws InvalidParameterValueException;
void checkRequestedIpAddresses(long networkId, String ip4, String ip6) throws InvalidParameterValueException;
}

View File

@ -38,6 +38,7 @@ public class NetworkProfile implements Network {
private TrafficType trafficType;
private String gateway;
private String cidr;
private String networkCidr;
private String ip6Gateway;
private String ip6Cidr;
private long networkOfferingId;
@ -65,6 +66,7 @@ public class NetworkProfile implements Network {
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();
@ -162,6 +164,11 @@ public class NetworkProfile implements Network {
return cidr;
}
@Override
public String getNetworkCidr() {
return networkCidr;
}
@Override
public long getNetworkOfferingId() {
return networkOfferingId;

View File

@ -19,9 +19,10 @@ package com.cloud.network;
import java.util.List;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
@ -33,6 +34,8 @@ import com.cloud.network.Networks.TrafficType;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.Pair;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
/**
* The NetworkService interface is the "public" api to entities that make requests to the orchestration engine
@ -66,10 +69,8 @@ public interface NetworkService {
IpAddress getIp(long id);
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
String domainSuffix, Long networkOfferingId, Boolean changeCidr, String guestVmCidr);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
@ -155,5 +156,13 @@ public interface NetworkService {
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId)
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
/* Requests an IP address for the guest nic */
String allocateSecondaryGuestIP(Account account, long zoneId, Long nicId,
Long networkId, String ipaddress) throws InsufficientAddressCapacityException;
boolean releaseSecondaryIpFromNic(long ipAddressId);
/* lists the nic informaton */
List<? extends Nic> listNics(ListNicsCmd listNicsCmd);
}

View File

@ -14,29 +14,23 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.resource;
package com.cloud.network;
import com.cloud.storage.VolumeVO;
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
import com.cloud.utils.component.Adapter;
import com.cloud.network.Networks.TrafficType;
/**
* DiskMounter mounts and unmounts disk for VMs
* to consume.
*
/* User can provide a Label, while configuring a zone, to specify
* a physical network that is to be used for a traffic type defined
* by CloudStack. See the enum data type TrafficType. This label is
* called Traffic label. This might encapsulate physical network
* specific properties like VLAN ID, name of virtual network object or more.
* The name of virtual network object is dependent on type of hypervisor.
* For example it is name of xenserver bridge in case of XenServer and
* name of virtual switch in case of VMware hypervisor
*/
public interface DiskPreparer extends Adapter {
/**
* Mounts a volumeVO and returns a path.
*
* @param vol
* @return
*/
public String mount(String vmName, VolumeVO vol, BootloaderType type);
/**
* Unmounts
*/
public boolean unmount(String path);
public interface TrafficLabel {
public TrafficType getTrafficType();
public String getNetworkLabel();
}

View File

@ -25,6 +25,7 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.net.Ip;
public interface RulesService {
Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll);
@ -43,7 +44,7 @@ public interface RulesService {
* @throws NetworkRuleConflictException
* if conflicts in the network rules are detected.
*/
PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, boolean openFirewall) throws NetworkRuleConflictException;
PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, Ip vmIp, boolean openFirewall) throws NetworkRuleConflictException;
/**
* Revokes a port forwarding rule
@ -66,7 +67,7 @@ public interface RulesService {
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm) throws NetworkRuleConflictException, ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
PortForwardingRule getPortForwardigRule(long ruleId);

View File

@ -24,6 +24,7 @@ import org.apache.cloudstack.api.command.user.securitygroup.CreateSecurityGroupC
import org.apache.cloudstack.api.command.user.securitygroup.DeleteSecurityGroupCmd;
import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupEgressCmd;
import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupIngressCmd;
import org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@ -45,5 +46,6 @@ public interface SecurityGroupService {
public List<? extends SecurityRule> authorizeSecurityGroupIngress(AuthorizeSecurityGroupIngressCmd cmd);
public List<? extends SecurityRule> authorizeSecurityGroupEgress(AuthorizeSecurityGroupEgressCmd cmd);
public boolean securityGroupRulesForVmSecIp(Long nicId, Long networkId,
String secondaryIp, boolean ruleAction);
}

View File

@ -41,7 +41,7 @@ public interface VpcService {
public VpcOffering getVpcOffering(long vpcOfferingId);
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices);
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices, Map<String, List<String>> serviceProviders);
public Vpc getVpc(long vpcId);
@ -246,5 +246,5 @@ public interface VpcService {
InsufficientAddressCapacityException, ConcurrentOperationException;
public Network updateVpcGuestNetwork(long networkId, String name, String displayText, Account callerAccount,
User callerUser, String domainSuffix, Long ntwkOffId, Boolean changeCidr);
User callerUser, String domainSuffix, Long ntwkOffId, Boolean changeCidr, String guestVmCidr);
}

View File

@ -77,6 +77,11 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
*/
boolean getLimitCpuUse();
/**
* @return Does this service plan support Volatile VM that is, discard VM's root disk and create a new one on reboot?
*/
boolean getVolatileVm();
/**
* @return the rate in megabits per sec to which a VM's network interface is throttled to
*/

View File

@ -71,7 +71,7 @@ public interface ResourceService {
boolean deleteCluster(DeleteClusterCmd cmd);
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate);
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate,Float memoryOvercommitRatio, Float cpuOvercommitRatio);
List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;

View File

@ -29,6 +29,8 @@ import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
@ -40,12 +42,12 @@ import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd;
import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
@ -55,12 +57,10 @@ import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import com.cloud.alert.Alert;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.Configuration;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;
@ -72,8 +72,6 @@ import com.cloud.host.Host;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.IpAddress;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.org.Cluster;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOsCategory;
@ -194,6 +192,34 @@ public interface ManagementService {
*/
Pair<List<? extends Alert>, Integer> searchForAlerts(ListAlertsCmd cmd);
/**
* Archive alerts
* @param cmd
* @return True on success. False otherwise.
*/
boolean archiveAlerts(ArchiveAlertsCmd cmd);
/**
* Delete alerts
* @param cmd
* @return True on success. False otherwise.
*/
boolean deleteAlerts(DeleteAlertsCmd cmd);
/**
* Archive events
* @param cmd
* @return True on success. False otherwise.
*/
boolean archiveEvents(ArchiveEventsCmd cmd);
/**
* Delete events
* @param cmd
* @return True on success. False otherwise.
*/
boolean deleteEvents(DeleteEventsCmd cmd);
/**
* list all the capacity rows in capacity operations table
*

View File

@ -19,7 +19,6 @@ package com.cloud.storage;
import java.util.Date;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
@ -55,28 +54,13 @@ public interface Snapshot extends ControlledEntity, Identity, InternalIdentity,
}
public enum State {
Allocated,
Creating,
CreatedOnPrimary,
BackingUp,
BackedUp,
Error;
private final static StateMachine2<State, Event, Snapshot> s_fsm = new StateMachine2<State, Event, Snapshot>();
public static StateMachine2<State, Event, Snapshot> getStateMachine() {
return s_fsm;
}
static {
s_fsm.addTransition(null, Event.CreateRequested, Creating);
s_fsm.addTransition(Creating, Event.OperationSucceeded, CreatedOnPrimary);
s_fsm.addTransition(Creating, Event.OperationNotPerformed, BackedUp);
s_fsm.addTransition(Creating, Event.OperationFailed, Error);
s_fsm.addTransition(CreatedOnPrimary, Event.BackupToSecondary, BackingUp);
s_fsm.addTransition(BackingUp, Event.OperationSucceeded, BackedUp);
s_fsm.addTransition(BackingUp, Event.OperationFailed, Error);
}
public String toString() {
return this.name();
}
@ -107,7 +91,7 @@ public interface Snapshot extends ControlledEntity, Identity, InternalIdentity,
Date getCreated();
Type getType();
Type getRecurringType();
State getState();

View File

@ -99,10 +99,7 @@ public interface StoragePool extends Identity, InternalIdentity {
/**
* @return
*/
String getStorageProvider();
/**
* @return
*/
String getStorageType();
Long getStorageProviderId();
boolean isInMaintenance();
}

View File

@ -17,11 +17,6 @@
package com.cloud.storage;
public enum StoragePoolStatus {
Creating,
Up,
PrepareForMaintenance,
ErrorInMaintenance,
CancelMaintenance,
Maintenance,
Removed;
Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance,
ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
}

View File

@ -22,17 +22,10 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
public interface StorageService{
/**
@ -51,37 +44,6 @@ public interface StorageService{
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
UnknownHostException, ResourceUnavailableException;
/**
* Creates the database object for a volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
* name)
* @return the volume object
* @throws PermissionDeniedException
*/
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
/**
* Creates the volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
* name)
* @return the volume object
*/
Volume createVolume(CreateVolumeCmd cmd);
/**
* Resizes the volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria
* @return the volume object
*/
Volume resizeVolume(ResizeVolumeCmd cmd);
/**
* Delete the storage pool
*
@ -120,19 +82,4 @@ public interface StorageService{
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
public StoragePool getStoragePool(long id);
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
/**
* Uploads the volume to secondary storage
*
* @param UploadVolumeCmd cmd
*
* @return Volume object
*/
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
}

View File

@ -39,9 +39,12 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
Resizing("The volume is being resized"),
Expunging("The volume is being expunging"),
Expunged("The volume is being expunging"),
Destroy("The volume is destroyed, and can't be recovered."),
Destroying("The volume is destroying, and can't be recovered."),
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage"),
Uploading("volume is uploading"),
Uploaded("volume is uploaded");
String _description;
@ -70,12 +73,15 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
s_fsm.addTransition(Uploaded, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
s_fsm.addTransition(Creating, Event.CopyFailed, Uploaded);// Copying volume from sec to primary failed.
s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging);
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging);
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
@ -83,6 +89,9 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroy);
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
}
}
@ -110,7 +119,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
/**
* @return total size of the partition
*/
long getSize();
Long getSize();
/**
* @return the vm instance id

View File

@ -0,0 +1,81 @@
/*
* 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 org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.user.Account;
public interface VolumeApiService {
/**
* Creates the database object for a volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
* name)
* @return the volume object
* @throws PermissionDeniedException
*/
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
/**
* Creates the volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
* name)
* @return the volume object
*/
Volume createVolume(CreateVolumeCmd cmd);
/**
* Resizes the volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria
* @return the volume object
*/
Volume resizeVolume(ResizeVolumeCmd cmd);
Volume migrateVolume(MigrateVolumeCmd cmd) throws ConcurrentOperationException;
/**
* Uploads the volume to secondary storage
*
* @param UploadVolumeCmd cmd
*
* @return Volume object
*/
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
Volume attachVolumeToVM(AttachVolumeCmd command);
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
}

View File

@ -25,6 +25,7 @@ import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
@ -32,6 +33,8 @@ import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
public interface TemplateService {
@ -87,4 +90,11 @@ public interface TemplateService {
List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd,
Account templateOwner) throws ResourceAllocationException;
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command)
throws CloudRuntimeException;
}

View File

@ -37,6 +37,7 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
featured, // returns templates that have been marked as featured and public
self, // returns templates that have been registered or created by the calling user
selfexecutable, // same as self, but only returns templates that are ready to be deployed with
shared, // including templates that have been granted to the calling user by another user
sharedexecutable, // ready templates that have been granted to the calling user by another user
executable, // templates that are owned by the calling user, or public templates, that can be used to deploy a
community, // returns templates that have been marked as public but not featured

View File

@ -62,7 +62,7 @@ public interface AccountService {
* @return the user if created successfully, null otherwise
*/
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
Map<String, String> details, String accountUUID, String userUUID, Integer regionId);
Map<String, String> details);
/**
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
@ -77,7 +77,7 @@ public interface AccountService {
User getSystemUser();
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Integer regionId);
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId);
boolean isAdmin(short accountType);

View File

@ -27,7 +27,7 @@ import com.cloud.utils.Pair;
public interface DomainService {
Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID, Integer regionId);
Domain createDomain(String name, Long parentId, String networkDomain);
Domain getDomain(long id);

View File

@ -151,4 +151,5 @@ public interface Nic extends Identity, InternalIdentity {
String getIp6Cidr();
String getIp6Address();
boolean getSecondaryIp();
}

View File

@ -50,6 +50,8 @@ public class NicProfile implements InternalIdentity {
Integer deviceId;
String dns1;
String dns2;
String ip6Dns1;
String ip6Dns2;
Integer networkRate;
boolean isSecurityGroupEnabled;
String name;
@ -332,4 +334,20 @@ public class NicProfile implements InternalIdentity {
this.requestedIpv6 = requestedIpv6;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
}

View File

@ -16,31 +16,21 @@
// under the License.
package com.cloud.vm;
import java.util.List;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
/**
*
* be an information carrier within one thread only.
*
* Nic represents one nic on the VM.
*/
public class VirtualEnvironment {
public interface NicSecondaryIp extends ControlledEntity, Identity, InternalIdentity {
/**
* The actual machine
* @return id in the CloudStack database
*/
public VirtualMachine machine;
/**
* Disks to assign to the machine in order.
*/
public List<VirtualDisk> disks;
/**
* Networks to assign to the machine.
*/
public List<VirtualNetwork> networks;
/**
* Boot options to assign to the machine.
*/
public String bootOptions;
long getId();
long getNicId();
String getIp4Address();
long getNetworkId();
long getVmId();
}

View File

@ -23,7 +23,6 @@ import javax.naming.InsufficientResourcesException;
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
@ -103,24 +102,6 @@ public interface UserVmService {
*/
UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
/**
* Attaches the specified volume to the specified VM
*
* @param cmd
* - the command specifying volumeId and vmId
* @return the Volume object if attach worked successfully.
*/
Volume attachVolumeToVM(AttachVolumeCmd cmd);
/**
* Detaches the specified volume from the VM it is currently attached to.
*
* @param cmd
* - the command specifying volumeId
* @return the Volume object if detach worked successfully.
*/
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException,
ResourceAllocationException;
@ -151,28 +132,6 @@ public interface UserVmService {
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
/**
* Create a template database record in preparation for creating a private template.
*
* @param cmd
* the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
* for the
* private template
* @param templateOwner
* TODO
* @return the vm template object if successful, null otherwise
* @throws ResourceAllocationException
*/
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd, Account templateOwner) throws ResourceAllocationException;
/**
* Creates a private template from a snapshot of a VM
*
* @param cmd
* - the command specifying snapshotId, name, description
* @return a template if successfully created, null otherwise
*/
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd cmd);
/**
* Creates a Basic Zone User VM in the database and returns the VM to the caller.

View File

@ -136,4 +136,10 @@ public interface VirtualMachineProfile<T extends VirtualMachine> {
BootloaderType getBootLoaderType();
Map<Param, Object> getParameters();
Float getCpuOvercommitRatio();
Float getMemoryOvercommitRatio();
}

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.acl;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.RequestLimitException;
import com.cloud.user.User;
import com.cloud.utils.component.Adapter;
@ -27,5 +26,5 @@ public interface APIChecker extends Adapter {
// If true, apiChecker has checked the operation
// If false, apiChecker is unable to handle the operation or not implemented
// On exception, checkAccess failed don't allow
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException, RequestLimitException;
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException;
}

View File

@ -22,10 +22,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@Retention(RetentionPolicy.RUNTIME)
@Target({ FIELD })
public @interface ACL {
AccessType accessType() default AccessType.ListEntry;
boolean checkKeyAccess() default false;
boolean checkValueAccess() default false;
}

View File

@ -46,6 +46,7 @@ public class ApiConstants {
public static final String COMPONENT = "component";
public static final String CPU_NUMBER = "cpunumber";
public static final String CPU_SPEED = "cpuspeed";
public static final String CPU_OVERCOMMIT_RATIO="cpuovercommitratio";
public static final String CREATED = "created";
public static final String CUSTOMIZED = "customized";
public static final String DESCRIPTION = "description";
@ -58,6 +59,8 @@ public class ApiConstants {
public static final String DISPLAY_TEXT = "displaytext";
public static final String DNS1 = "dns1";
public static final String DNS2 = "dns2";
public static final String IP6_DNS1 = "ip6dns1";
public static final String IP6_DNS2 = "ip6dns2";
public static final String DOMAIN = "domain";
public static final String DOMAIN_ID = "domainid";
public static final String DURATION = "duration";
@ -119,6 +122,7 @@ public class ApiConstants {
public static final String MAX = "max";
public static final String MAX_SNAPS = "maxsnaps";
public static final String MEMORY = "memory";
public static final String MEMORY_OVERCOMMIT_RATIO="memoryovercommitratio";
public static final String MODE = "mode";
public static final String NAME = "name";
public static final String METHOD_NAME = "methodname";
@ -218,6 +222,7 @@ public class ApiConstants {
public static final String VM_LIMIT = "vmlimit";
public static final String VM_TOTAL = "vmtotal";
public static final String VNET = "vnet";
public static final String IS_VOLATILE = "isvolatile";
public static final String VOLUME_ID = "volumeid";
public static final String ZONE_ID = "zoneid";
public static final String ZONE_NAME = "zonename";
@ -355,7 +360,10 @@ public class ApiConstants {
public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize";
public static final String DEFAULT_ZONE_ID = "defaultzoneid";
public static final String GUID = "guid";
public static final String VSWITCH_TYPE_GUEST_TRAFFIC = "guestvswitchtype";
public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";
public static final String VSWITCH_NAME_PUBLIC_TRAFFIC = "publicvswitchname";
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";
@ -374,9 +382,8 @@ public class ApiConstants {
public static final String VSM_CONFIG_STATE = "vsmconfigstate";
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
public static final String ADD_VSM_FLAG = "addvsmflag";
public static final String END_POINT = "endpoint";
public static final String REGION_ID = "regionid";
public static final String IS_PROPAGATE = "ispropagate";
public static final String END_POINT = "endpoint";
public static final String REGION_ID = "regionid";
public static final String VPC_OFF_ID = "vpcofferingid";
public static final String NETWORK = "network";
public static final String VPC_ID = "vpcid";
@ -443,6 +450,16 @@ public class ApiConstants {
public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
public static final String IMAGE_STORE_UUID = "imagestoreuuid";
public static final String GUEST_VM_CIDR = "guestvmcidr";
public static final String NETWORK_CIDR = "networkcidr";
public static final String RESERVED_IP_RANGE = "reservediprange";
public static final String UCS_MANAGER_ID = "ucsmanagerid";
public static final String UCS_PROFILE_DN = "profiledn";
public static final String UCS_BLADE_DN = "bladedn";
public static final String UCS_BLADE_ID = "bladeid";
public static final String VM_GUEST_IP = "vmguestip";
public static final String OLDER_THAN = "olderthan";
public enum HostDetails {
all, capacity, events, stats, min;

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.api;
/**
* Enum class for various API error code used in CloudStack
* @author minc
*
*/
public enum ApiErrorCode {

View File

@ -62,6 +62,7 @@ import com.cloud.resource.ResourceService;
import com.cloud.server.ManagementService;
import com.cloud.server.TaggedResourceService;
import com.cloud.storage.StorageService;
import com.cloud.storage.VolumeApiService;
import com.cloud.storage.snapshot.SnapshotService;
import com.cloud.template.TemplateService;
import com.cloud.user.Account;
@ -69,7 +70,6 @@ import com.cloud.user.AccountService;
import com.cloud.user.DomainService;
import com.cloud.user.ResourceLimitService;
import com.cloud.utils.Pair;
import com.cloud.vm.BareMetalVmService;
import com.cloud.vm.UserVmService;
import com.cloud.vm.snapshot.VMSnapshotService;
@ -102,6 +102,7 @@ public abstract class BaseCmd {
@Inject public UserVmService _userVmService;
@Inject public ManagementService _mgr;
@Inject public StorageService _storageService;
@Inject public VolumeApiService _volumeService;
@Inject public ResourceService _resourceService;
@Inject public NetworkService _networkService;
@Inject public TemplateService _templateService;

View File

@ -53,6 +53,8 @@ import org.apache.cloudstack.api.response.LoadBalancerResponse;
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.NicResponse;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
@ -163,6 +165,8 @@ import com.cloud.user.User;
import com.cloud.user.UserAccount;
import com.cloud.uservm.UserVm;
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;
@ -385,4 +389,7 @@ public interface ResponseGenerator {
TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
NicSecondaryIpResponse createSecondaryIPToNicResponse(String ip,
Long nicId, Long networkId);
public NicResponse createNicResponse(Nic result);
}

View File

@ -43,7 +43,7 @@ public class ServerApiException extends CloudRuntimeException {
super(description, cause);
_errorCode = errorCode;
_description = description;
if (cause instanceof CloudRuntimeException || cause instanceof CloudException ) {
if (cause instanceof CloudRuntimeException) {
CloudRuntimeException rt = (CloudRuntimeException) cause;
ArrayList<String> idList = rt.getIdProxyList();
if (idList != null) {
@ -52,6 +52,15 @@ public class ServerApiException extends CloudRuntimeException {
}
}
setCSErrorCode(rt.getCSErrorCode());
} else if (cause instanceof CloudException) {
CloudException rt = (CloudException) cause;
ArrayList<String> idList = rt.getIdProxyList();
if (idList != null) {
for (int i = 0; i < idList.size(); i++) {
addProxyObject(idList.get(i));
}
}
setCSErrorCode(rt.getCSErrorCode());
}
}

View File

@ -78,19 +78,7 @@ public class CreateAccountCmd extends BaseCmd {
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
private Map<String, String> details;
//@Parameter(name = ApiConstants.REGION_DETAILS, type = CommandType.MAP, description = "details for account used to store region specific parameters")
//private Map<String, String> regionDetails;
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.STRING, description="Account UUID, required for adding account from another Region")
private String accountUUID;
@Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from another Region")
private String userUUID;
@Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the account")
private Integer regionId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -145,18 +133,6 @@ public class CreateAccountCmd extends BaseCmd {
return params;
}
public String getAccountUUID() {
return accountUUID;
}
public String getUserUUID() {
return userUUID;
}
public Integer getRegionId() {
return regionId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -174,8 +150,8 @@ public class CreateAccountCmd extends BaseCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails(),
getAccountUUID(), getUserUUID(), getRegionId());
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(),
getDomainId(), getNetworkDomain(), getDetails());
if (userAccount != null) {
AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount);
response.setResponseName(getCommandName());

View File

@ -48,11 +48,8 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
required=true, description="Account id")
private Long id;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -62,10 +59,6 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
return id;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -103,7 +96,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Account Id: "+getId());
boolean result = _regionService.deleteUserAccount(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());

View File

@ -58,11 +58,8 @@ public class DisableAccountCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.LOCK, type=CommandType.BOOLEAN, required=true, description="If true, only lock the account; else disable the account")
private Boolean lockRequested;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -79,14 +76,10 @@ public class DisableAccountCmd extends BaseAsyncCmd {
return domainId;
}
public Boolean getIsPropagate() {
return isPropagate;
}
public Boolean getLockRequested() {
return lockRequested;
}
return lockRequested;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -124,7 +117,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
Account result = _regionService.disableAccount(this);
Account result = _regionService.disableAccount(this);
if (result != null){
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());

View File

@ -50,11 +50,8 @@ public class EnableAccountCmd extends BaseCmd {
description="Enables specified account in this domain.")
private Long domainId;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -71,10 +68,6 @@ public class EnableAccountCmd extends BaseCmd {
return domainId;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -101,7 +94,7 @@ public class EnableAccountCmd extends BaseCmd {
@Override
public void execute(){
Account result = _regionService.enableAccount(this);
Account result = _regionService.enableAccount(this);
if (result != null){
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());

View File

@ -63,11 +63,8 @@ public class UpdateAccountCmd extends BaseCmd{
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
private Map details;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -102,10 +99,6 @@ public class UpdateAccountCmd extends BaseCmd{
return params;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -131,7 +124,7 @@ public class UpdateAccountCmd extends BaseCmd{
@Override
public void execute(){
Account result = _regionService.updateAccount(this);
Account result = _regionService.updateAccount(this);
if (result != null){
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());

View File

@ -20,6 +20,10 @@ package org.apache.cloudstack.api.command.admin.cluster;
import java.util.ArrayList;
import java.util.List;
import com.cloud.exception.InvalidParameterValueException;
import org.apache.cloudstack.api.*;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@ -81,6 +85,40 @@ public class AddClusterCmd extends BaseCmd {
@Parameter(name = ApiConstants.VSM_IPADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the VSM associated with this cluster")
private String vsmipaddress;
@Parameter (name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false , description = "value of the cpu overcommit ratio, defaults to 1")
private String cpuovercommitRatio;
@Parameter(name = ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false ,description = "value of the default ram overcommit ratio, defaults to 1")
private String memoryovercommitratio;
@Parameter(name = ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, type = CommandType.STRING, required = false, description = "Type of virtual switch used for guest traffic in the cluster. Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed vSwitch)")
private String vSwitchTypeGuestTraffic;
@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.")
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.")
private String vSwitchNamePublicTraffic;
public String getVSwitchTypeGuestTraffic() {
return vSwitchTypeGuestTraffic;
}
public String getVSwitchTypePublicTraffic() {
return vSwitchTypePublicTraffic;
}
public String getVSwitchNameGuestTraffic() {
return vSwitchNameGuestTraffic;
}
public String getVSwitchNamePublicTraffic() {
return vSwitchNamePublicTraffic;
}
public String getVSMIpaddress() {
return vsmipaddress;
}
@ -147,9 +185,26 @@ public class AddClusterCmd extends BaseCmd {
this.allocationState = allocationState;
}
public Float getCpuOvercommitRatio (){
if(cpuovercommitRatio != null){
return Float.parseFloat(cpuovercommitRatio);
}
return 1.0f;
}
public Float getMemoryOvercommitRaito (){
if (memoryovercommitratio != null){
return Float.parseFloat(memoryovercommitratio);
}
return 1.0f;
}
@Override
public void execute(){
try {
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should not be less than 1");
}
List<? extends Cluster> result = _resourceService.discoverCluster(this);
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();

View File

@ -54,6 +54,13 @@ public class UpdateClusterCmd extends BaseCmd {
@Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
private String managedState;
@Parameter(name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of cpu overcommit ratio")
private String cpuovercommitratio;
@Parameter(name=ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of ram overcommit ratio")
private String memoryovercommitratio;
public String getClusterName() {
return clusterName;
}
@ -100,6 +107,20 @@ public class UpdateClusterCmd extends BaseCmd {
this.managedState = managedstate;
}
public Float getCpuOvercommitRatio (){
if(cpuovercommitratio != null){
return Float.parseFloat(cpuovercommitratio);
}
return 1.0f;
}
public Float getMemoryOvercommitRaito (){
if (memoryovercommitratio != null){
return Float.parseFloat(memoryovercommitratio);
}
return 1.0f;
}
@Override
public void execute(){
Cluster cluster = _resourceService.getCluster(getId());
@ -107,7 +128,11 @@ public class UpdateClusterCmd extends BaseCmd {
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
}
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate());
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one");
}
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio());
if (result != null) {
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
clusterResponse.setResponseName(getCommandName());

View File

@ -49,12 +49,6 @@ public class CreateDomainCmd extends BaseCmd {
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for networks in the domain")
private String networkDomain;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.STRING, description="Domain UUID, required for adding domain from another Region")
private String domainUUID;
@Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the Domain")
private Integer regionId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -71,14 +65,6 @@ public class CreateDomainCmd extends BaseCmd {
return networkDomain;
}
public String getDomainUUID() {
return domainUUID;
}
public Integer getRegionId() {
return regionId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -96,7 +82,7 @@ public class CreateDomainCmd extends BaseCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID(), getRegionId());
Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain());
if (domain != null) {
DomainResponse response = _responseGenerator.createDomainResponse(domain);
response.setResponseName(getCommandName());

View File

@ -50,11 +50,8 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.CLEANUP, type=CommandType.BOOLEAN, description="true if all domain resources (child domains, accounts) have to be cleaned up, false otherwise")
private Boolean cleanup;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean propagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -67,10 +64,6 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
return cleanup;
}
public Boolean isPropagate() {
return propagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -52,11 +52,8 @@ public class UpdateDomainCmd extends BaseCmd {
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the domain's networks; empty string will update domainName with NULL value")
private String networkDomain;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -73,10 +70,6 @@ public class UpdateDomainCmd extends BaseCmd {
return networkDomain;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -95,7 +88,7 @@ public class UpdateDomainCmd extends BaseCmd {
public void execute(){
UserContext.current().setEventDetails("Domain Id: "+getId());
Domain domain = _regionService.updateDomain(this);
if (domain != null) {
DomainResponse response = _responseGenerator.createDomainResponse(domain);
response.setResponseName(getCommandName());

View File

@ -31,6 +31,7 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
@APICommand(name = "ldapConfig", description="Configure the LDAP context for this site.", responseObject=LDAPConfigResponse.class, since="3.0.0")
@ -43,7 +44,10 @@ public class LDAPConfigCmd extends BaseCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, required=true, description="Hostname or ip address of the ldap server eg: my.ldap.com")
@Parameter(name=ApiConstants.LIST_ALL, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com")
private String listall;
@Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com")
private String hostname;
@Parameter(name=ApiConstants.PORT, type=CommandType.INTEGER, description="Specify the LDAP port if required, default is 389.")
@ -52,10 +56,10 @@ public class LDAPConfigCmd extends BaseCmd {
@Parameter(name=ApiConstants.USE_SSL, type=CommandType.BOOLEAN, description="Check Use SSL if the external LDAP server is configured for LDAP over SSL.")
private Boolean useSSL;
@Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, required=true, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.")
@Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.")
private String searchBase;
@Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, required=true, description="You specify a query filter here, which narrows down the users, who can be part of this domain.")
@Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, description="You specify a query filter here, which narrows down the users, who can be part of this domain.")
private String queryFilter;
@Parameter(name=ApiConstants.BIND_DN, type=CommandType.STRING, description="Specify the distinguished name of a user with the search permission on the directory.")
@ -74,6 +78,10 @@ public class LDAPConfigCmd extends BaseCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getListAll() {
return listall == null ? "false" : listall;
}
public String getBindPassword() {
return bindPassword;
}
@ -82,30 +90,56 @@ public class LDAPConfigCmd extends BaseCmd {
return bindDN;
}
public void setBindDN(String bdn) {
this.bindDN=bdn;
}
public String getQueryFilter() {
return queryFilter;
}
public void setQueryFilter(String queryFilter) {
this.queryFilter=queryFilter;
}
public String getSearchBase() {
return searchBase;
}
public void setSearchBase(String searchBase) {
this.searchBase=searchBase;
}
public Boolean getUseSSL() {
return useSSL == null ? Boolean.FALSE : Boolean.TRUE;
return useSSL == null ? Boolean.FALSE : useSSL;
}
public void setUseSSL(Boolean useSSL) {
this.useSSL=useSSL;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname=hostname;
}
public Integer getPort() {
return port <= 0 ? 389 : port;
}
public void setPort(Integer port) {
this.port=port;
}
public String getTrustStore() {
return trustStore;
}
public void setTrustStore(String trustStore) {
this.trustStore=trustStore;
}
public String getTrustStorePassword() {
return trustStorePassword;
@ -122,12 +156,25 @@ public class LDAPConfigCmd extends BaseCmd {
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
try {
boolean result = _configService.updateLDAP(this);
if (result){
LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
if ("true".equalsIgnoreCase(getListAll())){
// return the existing conf
LDAPConfigCmd cmd = _configService.listLDAPConfig(this);
LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(cmd.getHostname(), cmd.getPort(), cmd.getUseSSL(),
cmd.getQueryFilter(), cmd.getSearchBase(), cmd.getBindDN());
lr.setResponseName(getCommandName());
this.setResponseObject(lr);
}
else if (getHostname()==null || getSearchBase() == null || getQueryFilter() == null) {
throw new InvalidParameterValueException("You need to provide hostname, serachbase and queryfilter to configure your LDAP server");
}
else {
boolean result = _configService.updateLDAP(this);
if (result){
LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
lr.setResponseName(getCommandName());
this.setResponseObject(lr);
}
}
}
catch (NamingException ne){
ne.printStackTrace();

View File

@ -59,6 +59,9 @@ public class CreateServiceOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.LIMIT_CPU_USE, type=CommandType.BOOLEAN, description="restrict the CPU usage to committed service offering")
private Boolean limitCpuUse;
@Parameter(name=ApiConstants.IS_VOLATILE, type=CommandType.BOOLEAN, description="true if the virtual machine needs to be volatile so that on every reboot of VM, original root disk is dettached then destroyed and a fresh root disk is created and attached to VM")
private Boolean isVolatile;
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the service offering. Values are local and shared.")
private String storageType;
@ -106,11 +109,15 @@ public class CreateServiceOfferingCmd extends BaseCmd {
}
public Boolean getOfferHa() {
return offerHa;
return offerHa == null ? false : offerHa;
}
public Boolean GetLimitCpuUse() {
return limitCpuUse;
return limitCpuUse == null ? false : limitCpuUse;
}
public Boolean getVolatileVm() {
return isVolatile == null ? false : isVolatile;
}
public String getStorageType() {

View File

@ -0,0 +1,100 @@
// 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.resource;
import java.util.Date;
import java.util.List;
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.AlertResponse;
import org.apache.cloudstack.api.response.ConditionResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
@APICommand(name = "archiveAlerts", description = "Archive one or more alerts.", responseObject = SuccessResponse.class)
public class ArchiveAlertsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ArchiveAlertsCmd.class.getName());
private static final String s_name = "archivealertsresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AlertResponse.class,
description = "the IDs of the alerts")
private List<Long> ids;
@Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive alerts older than this date (use format \"yyyy-MM-dd\")")
private Date olderThan;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by alert type")
private String type;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public List<Long> getIds() {
return ids;
}
public Date getOlderThan() {
return olderThan;
}
public String getType() {
return type;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
if(ids == null && type == null && olderThan == null) {
throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
}
boolean result = _mgr.archiveAlerts(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Alerts, one or more parameters has invalid values");
}
}
}

View File

@ -0,0 +1,99 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.admin.resource;
import java.util.Date;
import java.util.List;
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.AlertResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
@APICommand(name = "deleteAlerts", description = "Delete one or more alerts.", responseObject = SuccessResponse.class)
public class DeleteAlertsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteAlertsCmd.class.getName());
private static final String s_name = "deletealertsresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AlertResponse.class,
description = "the IDs of the alerts")
private List<Long> ids;
@Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete alerts older than (including) this date (use format \"yyyy-MM-dd\")")
private Date olderThan;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by alert type")
private String type;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public List<Long> getIds() {
return ids;
}
public Date getOlderThan() {
return olderThan;
}
public String getType() {
return type;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
if(ids == null && type == null && olderThan == null) {
throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
}
boolean result = _mgr.deleteAlerts(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Alerts, one or more parameters has invalid values");
}
}
}

View File

@ -22,8 +22,8 @@ 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.DiskOfferingResponse;
import org.apache.cloudstack.api.response.DomainRouterResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.log4j.Logger;
import com.cloud.network.router.VirtualRouter;
@ -42,7 +42,7 @@ public class UpgradeRouterCmd extends BaseCmd {
required=true, description="The ID of the router")
private Long id;
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType = DiskOfferingResponse.class,
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType = ServiceOfferingResponse.class,
required=true, description="the service offering ID to apply to the domain router")
private Long serviceOfferingId;

View File

@ -36,6 +36,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.storage.StoragePool;
import com.cloud.user.Account;
@SuppressWarnings("rawtypes")
@APICommand(name = "createStoragePool", description="Creates a storage pool.", responseObject=StoragePoolResponse.class)
public class CreateStoragePoolCmd extends BaseCmd {
@ -48,7 +49,7 @@ public class CreateStoragePoolCmd extends BaseCmd {
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
required=true, description="the cluster ID for the storage pool")
description="the cluster ID for the storage pool")
private Long clusterId;
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="the details for the storage pool")
@ -58,7 +59,7 @@ public class CreateStoragePoolCmd extends BaseCmd {
private String storagePoolName;
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
required=true, description="the Pod ID for the storage pool")
description="the Pod ID for the storage pool")
private Long podId;
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the storage pool")
@ -70,6 +71,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
required=true, description="the Zone ID for the storage pool")
private Long zoneId;
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING,
required=false, description="the storage provider uuid")
private String storageProviderUuid;
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
required=false, description="the scope of the storage: cluster or zone")
private String scope;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -102,6 +111,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
public Long getZoneId() {
return zoneId;
}
public String getStorageProviderUuid() {
return this.storageProviderUuid;
}
public String getScope() {
return this.scope;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -23,7 +23,7 @@ import org.apache.cloudstack.api.BaseCmd;
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.DiskOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.log4j.Logger;
@ -48,7 +48,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
required=true, description="The ID of the system vm")
private Long id;
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=DiskOfferingResponse.class,
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class,
required=true, description="the service offering ID to apply to the system vm")
private Long serviceOfferingId;

View File

@ -65,12 +65,6 @@ public class CreateUserCmd extends BaseCmd {
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="Unique username.")
private String username;
@Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from another Region")
private String userUUID;
@Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the User")
private Integer regionId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -107,14 +101,6 @@ public class CreateUserCmd extends BaseCmd {
return username;
}
public String getUserUUID() {
return userUUID;
}
public Integer getRegionId() {
return regionId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -146,7 +132,7 @@ public class CreateUserCmd extends BaseCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName());
User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID(), getRegionId());
User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId());
if (user != null) {
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());

View File

@ -33,7 +33,7 @@ import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.UserContext;
@APICommand(name = "deleteUser", description="Creates a user for an account", responseObject=UserResponse.class)
@APICommand(name = "deleteUser", description="Deletes a user for an account", responseObject=SuccessResponse.class)
public class DeleteUserCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteUserCmd.class.getName());
@ -42,14 +42,11 @@ public class DeleteUserCmd extends BaseCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class, required=true, description="Deletes a user")
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class, required=true, description="id of the user to be deleted")
private Long id;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -58,10 +55,6 @@ public class DeleteUserCmd extends BaseCmd {
return id;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -49,11 +49,8 @@ public class DisableUserCmd extends BaseAsyncCmd {
required=true, description="Disables user by user ID.")
private Long id;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -62,10 +59,6 @@ public class DisableUserCmd extends BaseAsyncCmd {
return id;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -100,7 +93,7 @@ public class DisableUserCmd extends BaseAsyncCmd {
public void execute(){
UserContext.current().setEventDetails("UserId: "+getId());
UserAccount user = _regionService.disableUser(this);
if (user != null){
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());

View File

@ -46,11 +46,8 @@ public class EnableUserCmd extends BaseCmd {
required=true, description="Enables user by user ID.")
private Long id;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -59,10 +56,6 @@ public class EnableUserCmd extends BaseCmd {
return id;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -86,7 +79,7 @@ public class EnableUserCmd extends BaseCmd {
public void execute(){
UserContext.current().setEventDetails("UserId: "+getId());
UserAccount user = _regionService.enableUser(this);
if (user != null){
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());

View File

@ -71,11 +71,8 @@ public class UpdateUserCmd extends BaseCmd {
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="Unique username")
private String username;
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
private Boolean isPropagate;
@Inject RegionService _regionService;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -116,10 +113,6 @@ public class UpdateUserCmd extends BaseCmd {
return username;
}
public Boolean getIsPropagate() {
return isPropagate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -143,7 +136,7 @@ public class UpdateUserCmd extends BaseCmd {
public void execute(){
UserContext.current().setEventDetails("UserId: "+getId());
UserAccount user = _regionService.updateUser(this);
if (user != null){
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());

View File

@ -16,7 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.vpc;
import java.util.List;
import java.util.*;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -52,6 +52,10 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
description="services supported by the vpc offering")
private List<String> supportedServices;
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. " +
"If not specified, the provider for the service will be mapped to the default provider on the physical network")
private Map<String, String> serviceProviderList;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -68,10 +72,33 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
return supportedServices;
}
public Map<String, List<String>> getServiceProviders() {
Map<String, List<String>> serviceProviderMap = null;
if (serviceProviderList != null && !serviceProviderList.isEmpty()) {
serviceProviderMap = new HashMap<String, List<String>>();
Collection servicesCollection = serviceProviderList.values();
Iterator iter = servicesCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> services = (HashMap<String, String>) iter.next();
String service = services.get("service");
String provider = services.get("provider");
List<String> providerList = null;
if (serviceProviderMap.containsKey(service)) {
providerList = serviceProviderMap.get(service);
} else {
providerList = new ArrayList<String>();
}
providerList.add(provider);
serviceProviderMap.put(service, providerList);
}
}
return serviceProviderMap;
}
@Override
public void create() throws ResourceAllocationException {
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices());
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders());
if (vpcOff != null) {
this.setEntityId(vpcOff.getId());
this.setEntityUuid(vpcOff.getUuid());

View File

@ -46,6 +46,12 @@ public class CreateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2;
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
private String ip6Dns1;
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
private String ip6Dns2;
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
private String guestCidrAddress;
@ -89,6 +95,14 @@ public class CreateZoneCmd extends BaseCmd {
return dns2;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public String getGuestCidrAddress() {
return guestCidrAddress;
}

View File

@ -48,6 +48,12 @@ public class UpdateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2;
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
private String ip6Dns1;
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
private String ip6Dns2;
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
private String guestCidrAddress;
@ -105,6 +111,14 @@ public class UpdateZoneCmd extends BaseCmd {
return id;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public String getInternalDns1() {
return internalDns1;
}

View File

@ -26,7 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
@ -56,7 +56,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
required = true, description = "availability zone for the auto deployed virtual machine")
private Long zoneId;
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class,
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class,
required = true, description = "the service offering of the auto deployed virtual machine")
private Long serviceOfferingId;

View File

@ -52,8 +52,12 @@ public class ListCapabilitiesCmd extends BaseCmd {
response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired"));
response.setAllowUsersCreateProjects((Boolean)capabilities.get("allowusercreateprojects"));
response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
response.setApiLimitInterval((Integer)capabilities.get("apiLimitInterval"));
response.setApiLimitMax((Integer)capabilities.get("apiLimitMax"));
if (capabilities.containsKey("apiLimitInterval")) {
response.setApiLimitInterval((Integer) capabilities.get("apiLimitInterval"));
}
if (capabilities.containsKey("apiLimitMax")) {
response.setApiLimitMax((Integer) capabilities.get("apiLimitMax"));
}
response.setObjectName("capability");
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -0,0 +1,105 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.api.command.user.event;
import java.util.Date;
import java.util.List;
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.AlertResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@APICommand(name = "archiveEvents", description = "Archive one or more events.", responseObject = SuccessResponse.class)
public class ArchiveEventsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ArchiveEventsCmd.class.getName());
private static final String s_name = "archiveeventsresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = EventResponse.class,
description = "the IDs of the events")
private List<Long> ids;
@Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
private Date olderThan;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by event type")
private String type;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public List<Long> getIds() {
return ids;
}
public Date getOlderThan() {
return olderThan;
}
public String getType() {
return type;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
if(ids == null && type == null && olderThan == null) {
throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
}
boolean result = _mgr.archiveEvents(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Events, one or more parameters has invalid values");
}
}
}

View File

@ -0,0 +1,105 @@
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.cloudstack.api.command.user.event;
import java.util.Date;
import java.util.List;
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.AlertResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@APICommand(name = "deleteEvents", description = "Delete one or more events.", responseObject = SuccessResponse.class)
public class DeleteEventsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteEventsCmd.class.getName());
private static final String s_name = "deleteeventsresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = EventResponse.class,
description = "the IDs of the events")
private List<Long> ids;
@Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
private Date olderThan;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by event type")
private String type;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public List<Long> getIds() {
return ids;
}
public Date getOlderThan() {
return olderThan;
}
public String getType() {
return type;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
if(ids == null && type == null && olderThan == null) {
throw new InvalidParameterValueException("either ids, type or enddate must be specified");
}
boolean result = _mgr.deleteEvents(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Events, one or more parameters has invalid values");
}
}
}

View File

@ -94,6 +94,9 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
description="The network of the vm the Port Forwarding rule will be created for. " +
"Required when public Ip address is not associated with any Guest network yet (VPC case)")
private Long networkId;
@Parameter(name = ApiConstants.VM_GUEST_IP, type = CommandType.STRING, required = false,
description = "VM guest nic Secondary ip address for the port forwarding rule")
private String vmSecondaryIp;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
@ -104,6 +107,13 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
return ipAddressId;
}
public Ip getVmSecondaryIp() {
if (vmSecondaryIp == null) {
return null;
}
return new Ip(vmSecondaryIp);
}
@Override
public String getProtocol() {
return protocol.trim();
@ -300,8 +310,15 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
Ip privateIp = getVmSecondaryIp();
if (privateIp != null) {
if ( !privateIp.isIp4()) {
throw new InvalidParameterValueException("Invalid vm ip address");
}
}
try {
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, getOpenFirewall());
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall());
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} catch (NetworkRuleConflictException ex) {

View File

@ -52,7 +52,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
private String hypervisor;
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplateResponse.class,
description="list all isos by id")
description="list ISO by id")
private Long id;
@Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="true if the ISO is publicly available to all users, false otherwise.")
@ -61,11 +61,14 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
@Parameter(name=ApiConstants.IS_READY, type=CommandType.BOOLEAN, description="true if this ISO is ready to be deployed")
private Boolean ready;
@Parameter(name=ApiConstants.ISO_FILTER, type=CommandType.STRING, description="possible values are \"featured\", \"self\", \"self-executable\",\"executable\", and \"community\". " +
"* featured-ISOs that are featured and are publicself-ISOs that have been registered/created by the owner. " +
"* selfexecutable-ISOs that have been registered/created by the owner that can be used to deploy a new VM. " +
"* executable-all ISOs that can be used to deploy a new VM " +
"* community-ISOs that are public.")
@Parameter(name=ApiConstants.ISO_FILTER, type=CommandType.STRING, description="possible values are \"featured\", \"self\", \"selfexecutable\",\"sharedexecutable\",\"executable\", and \"community\". " +
"* featured : templates that have been marked as featured and public. " +
"* self : templates that have been registered or created by the calling user. " +
"* selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. " +
"* sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. " +
"* executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. " +
"* community : templates that have been marked as public but not featured. " +
"* all : all templates (only usable by admins).")
private String isoFilter = TemplateFilter.selfexecutable.toString();
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list all isos by name")

View File

@ -88,6 +88,10 @@ public class RegisterIsoCmd extends BaseCmd {
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
description="Register iso for the project")
private Long projectId;
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
description="Image store uuid")
private String imageStoreUuid;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -140,6 +144,10 @@ public class RegisterIsoCmd extends BaseCmd {
public String getChecksum() {
return checksum;
}
public String getImageStoreUuid() {
return this.imageStoreUuid;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -59,6 +59,9 @@ public class EnableStaticNatCmd extends BaseCmd{
description="The network of the vm the static nat will be enabled for." +
" Required when public Ip address is not associated with any Guest network yet (VPC case)")
private Long networkId;
@Parameter(name = ApiConstants.VM_GUEST_IP, type = CommandType.STRING, required = false,
description = "VM guest nic Secondary ip address for the port forwarding rule")
private String vmSecondaryIp;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -72,6 +75,13 @@ public class EnableStaticNatCmd extends BaseCmd{
return virtualMachineId;
}
public String getVmSecondaryIp() {
if (vmSecondaryIp == null) {
return null;
}
return vmSecondaryIp;
}
public long getNetworkId() {
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
Long ntwkId = null;
@ -110,7 +120,7 @@ public class EnableStaticNatCmd extends BaseCmd{
@Override
public void execute() throws ResourceUnavailableException{
try {
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false);
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false, getVmSecondaryIp());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -64,6 +64,9 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
description="network offering ID")
private Long networkOfferingId;
@Parameter(name=ApiConstants.GUEST_VM_CIDR, type=CommandType.STRING, description="CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR")
private String guestVmCidr;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -94,6 +97,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
}
return false;
}
private String getGuestVmCidr() {
return guestVmCidr;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -125,10 +132,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
Network result = null;
if (network.getVpcId() != null) {
result = _vpcService.updateVpcGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr());
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr());
} else {
result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr());
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr());
}
if (result != null) {

View File

@ -240,7 +240,7 @@ import com.cloud.user.UserContext;
@Override
public void create() throws ResourceAllocationException {
VirtualMachineTemplate template = null;
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
template = this._templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
if (template != null) {
this.setEntityId(template.getId());
this.setEntityUuid(template.getUuid());
@ -255,7 +255,7 @@ import com.cloud.user.UserContext;
public void execute() {
UserContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
VirtualMachineTemplate template = null;
template = _userVmService.createPrivateTemplate(this);
template = this._templateService.createPrivateTemplate(this);
if (template != null){
List<TemplateResponse> templateResponses;

View File

@ -110,7 +110,11 @@ public class RegisterTemplateCmd extends BaseCmd {
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
description="Register template for the project")
private Long projectId;
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
description="Image store uuid")
private String imageStoreUuid;
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
protected Map details;
@ -189,6 +193,10 @@ public class RegisterTemplateCmd extends BaseCmd {
public String getTemplateTag() {
return templateTag;
}
public String getImageStoreUuid() {
return this.imageStoreUuid;
}
public Map getDetails() {
if (details == null || details.isEmpty()) {

View File

@ -0,0 +1,197 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.vm;
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.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
import com.cloud.async.AsyncJob;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.Nic;
@APICommand(name = "addIpToNic", description = "Assigns secondary IP to NIC", responseObject = NicSecondaryIpResponse.class)
public class AddIpToVmNicCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AddIpToVmNicCmd.class.getName());
private static final String s_name = "addiptovmnicresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.NIC_ID, type=CommandType.UUID, entityType = NicResponse.class, required = true,
description="the ID of the nic to which you want to assign private IP")
private Long nicId;
@Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, required = false,
description = "Secondary IP Address")
private String ipAddr;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getEntityTable() {
return "nic_secondary_ips";
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
}
private long getZoneId() {
Network ntwk = _entityMgr.findById(Network.class, getNetworkId());
if (ntwk == null) {
throw new InvalidParameterValueException("Can't find zone id for specified");
}
return ntwk.getDataCenterId();
}
public Long getNetworkId() {
Nic nic = _entityMgr.findById(Nic.class, nicId);
if (nic == null) {
throw new InvalidParameterValueException("Can't find network id for specified nic");
}
Long networkId = nic.getNetworkId();
return networkId;
}
public Long getNicId() {
return nicId;
}
public String getIpaddress () {
if (ipAddr != null) {
return ipAddr;
} else {
return null;
}
}
public NetworkType getNetworkType() {
Network ntwk = _entityMgr.findById(Network.class, getNetworkId());
DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId());
return dc.getNetworkType();
}
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
return caller.getAccountId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_NET_IP_ASSIGN;
}
@Override
public String getEventDescription() {
return "associating ip to nic id: " + getNetworkId() + " in zone " + getZoneId();
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public static String getResultObjectName() {
return "addressinfo";
}
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException {
UserContext.current().setEventDetails("Nic Id: " + getNicId() );
String ip;
String secondaryIp = null;
if ((ip = getIpaddress()) != null) {
if (!NetUtils.isValidIp(ip)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid ip address " + ip);
}
}
try {
secondaryIp = _networkService.allocateSecondaryGuestIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNicId(), getNetworkId(), getIpaddress());
} catch (InsufficientAddressCapacityException e) {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
if (secondaryIp != null) {
if (getNetworkType() == NetworkType.Basic) {
// add security group rules for the secondary ip addresses
boolean success = false;
success = _securityGroupService.securityGroupRulesForVmSecIp(getNicId(), getNetworkId(), secondaryIp, (boolean) true);
if (success == false) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set security group rules for the secondary ip");
}
}
s_logger.info("Associated ip address to NIC : " + secondaryIp);
NicSecondaryIpResponse response = new NicSecondaryIpResponse();
response = _responseGenerator.createSecondaryIPToNicResponse(secondaryIp, getNicId(), getNetworkId());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign secondary ip to nic");
}
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public Long getSyncObjId() {
return getNetworkId();
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.IpAddress;
}
}

View File

@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -53,7 +54,6 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.IpAddresses;
import com.cloud.offering.DiskOffering;
@ -103,7 +103,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
private Long domainId;
//Network information
@ACL
@ACL(accessType = AccessType.UseNetwork)
@Parameter(name=ApiConstants.NETWORK_IDS, type=CommandType.LIST, collectionType=CommandType.UUID, entityType=NetworkResponse.class,
description="list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter")
private List<Long> networkIds;
@ -306,9 +306,6 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
if (requestedIpv6 != null) {
requestedIpv6 = requestedIpv6.toLowerCase();
}
if (requestedIpv6 != null) {
throw new InvalidParameterValueException("Cannot support specified IPv6 address!");
}
IpAddresses addrs = new IpAddresses(requestedIp, requestedIpv6);
ipToNetworkMap.put(networkId, addrs);
}
@ -388,7 +385,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (InsufficientCapacityException ex) {
s_logger.info(ex);
s_logger.trace(ex);
s_logger.info(ex.getMessage(), ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
}
} else {
@ -407,10 +404,6 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException{
try {
if (getIp6Address() != null) {
throw new InvalidParameterValueException("Cannot support specified IPv6 address!");
}
//Verify that all objects exist before passing them to the service
Account owner = _accountService.getActiveAccountById(getEntityOwnerId());
@ -477,7 +470,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
}
} catch (InsufficientCapacityException ex) {
s_logger.info(ex);
s_logger.trace(ex);
s_logger.trace(ex.getMessage(), ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);

View File

@ -0,0 +1,133 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.vm;
import java.util.ArrayList;
import java.util.List;
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.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import com.cloud.async.AsyncJob;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
@APICommand(name = "listNics", description = "list the vm nics IP to NIC", responseObject = NicResponse.class)
public class ListNicsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListNicsCmd.class.getName());
private static final String s_name = "listnics";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.NIC_ID, type=CommandType.UUID, entityType = NicResponse.class, required = false,
description="the ID of the nic to to list IPs")
private Long nicId;
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class, required = true,
description="the ID of the vm")
private Long vmId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getEntityTable() {
return "nics";
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
}
public Long getNicId() {
return nicId;
}
public Long getVmId() {
return vmId;
}
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
return caller.getAccountId();
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public static String getResultObjectName() {
return "addressinfo";
}
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException {
try {
List<? extends Nic> results = _networkService.listNics(this);
ListResponse<NicResponse> response = new ListResponse<NicResponse>();
List<NicResponse> resList = new ArrayList<NicResponse>(results.size());
for (Nic r : results) {
NicResponse resp = _responseGenerator.createNicResponse(r);
resp.setObjectName("nic");
resList.add(resp);
}
response.setResponses(resList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to list secondary ip address per nic ");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.IpAddress;
}
}

View File

@ -0,0 +1,172 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.vm;
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.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.async.AsyncJob;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.event.EventTypes;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
@APICommand(name = "removeIpFromNic", description="Assigns secondary IP to NIC.", responseObject=SuccessResponse.class)
public class RemoveIpFromVmNicCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(RemoveIpFromVmNicCmd.class.getName());
private static final String s_name = "removeipfromnicresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, required = true, entityType = NicSecondaryIpResponse.class,
description="the ID of the secondary ip address to nic")
private Long id;
// unexposed parameter needed for events logging
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.UUID, expose=false)
private Long ownerId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getEntityTable() {
return "nic_secondary_ips";
}
public Long getIpAddressId() {
return id;
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
}
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
return caller.getAccountId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_NET_IP_ASSIGN;
}
public NicSecondaryIp getIpEntry() {
NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
return nicSecIp;
}
@Override
public String getEventDescription() {
return ("Disassociating ip address with id=" + id);
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public static String getResultObjectName() {
return "addressinfo";
}
public Long getNetworkId() {
NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
if (nicSecIp != null) {
Long networkId = nicSecIp.getNetworkId();
return networkId;
} else {
return null;
}
}
public NetworkType getNetworkType() {
Network ntwk = _entityMgr.findById(Network.class, getNetworkId());
if (ntwk != null) {
DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId());
return dc.getNetworkType();
}
return null;
}
@Override
public void execute() throws InvalidParameterValueException {
UserContext.current().setEventDetails("Ip Id: " + id);
NicSecondaryIp nicSecIp = getIpEntry();
if (nicSecIp == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid IP id is passed");
}
if (getNetworkType() == NetworkType.Basic) {
//remove the security group rules for this secondary ip
boolean success = false;
success = _securityGroupService.securityGroupRulesForVmSecIp(nicSecIp.getNicId(), nicSecIp.getNetworkId(),nicSecIp.getIp4Address(), false);
if (success == false) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set security group rules for the secondary ip");
}
}
try {
boolean result = _networkService.releaseSecondaryIpFromNic(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove secondary ip address for the nic");
}
} catch (InvalidParameterValueException e) {
throw new InvalidParameterValueException("Removing guest ip from nic failed");
}
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.IpAddress;
}
}

View File

@ -22,6 +22,7 @@ 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.TemplateResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
@ -34,7 +35,7 @@ import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template or specific snapshot", responseObject=UserVmResponse.class, since="3.0.0")
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template or new template", responseObject=UserVmResponse.class, since="3.0.0")
public class RestoreVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
private static final String s_name = "restorevmresponse";
@ -43,6 +44,9 @@ public class RestoreVMCmd extends BaseAsyncCmd {
required=true, description="Virtual Machine ID")
private Long vmId;
@Parameter(name=ApiConstants.TEMPLATE_ID, type=CommandType.UUID, entityType = TemplateResponse.class, description="an optional template Id to restore vm from the new template")
private Long templateId;
@Override
public String getEventType() {
return EventTypes.EVENT_VM_RESTORE;
@ -85,4 +89,8 @@ public class RestoreVMCmd extends BaseAsyncCmd {
public long getVmId() {
return vmId;
}
public Long getTemplateId() {
return templateId;
}
}

View File

@ -119,7 +119,7 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
Volume result = _userVmService.attachVolumeToVM(this);
Volume result = _volumeService.attachVolumeToVM(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());

View File

@ -153,7 +153,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException{
Volume volume = _storageService.allocVolume(this);
Volume volume = this._volumeService.allocVolume(this);
if (volume != null) {
this.setEntityId(volume.getId());
this.setEntityUuid(volume.getUuid());
@ -165,7 +165,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
Volume volume = _storageService.createVolume(this);
Volume volume = _volumeService.createVolume(this);
if (volume != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
//FIXME - have to be moved to ApiResponseHelper

View File

@ -80,7 +80,7 @@ public class DeleteVolumeCmd extends BaseCmd {
@Override
public void execute() throws ConcurrentOperationException {
UserContext.current().setEventDetails("Volume Id: "+getId());
boolean result = _storageService.deleteVolume(id, UserContext.current().getCaller());
boolean result = this._volumeService.deleteVolume(id, UserContext.current().getCaller());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -130,7 +130,7 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
Volume result = _userVmService.detachVolumeFromVM(this);
Volume result = _volumeService.detachVolumeFromVM(this);
if (result != null){
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName("volume");

View File

@ -92,7 +92,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
public void execute(){
Volume result;
try {
result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
result = _volumeService.migrateVolume(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());

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