Merge branch 'master' into ui-new-project-switcher

This commit is contained in:
Brian Federle 2013-04-16 11:02:14 -07:00
commit a7489889f2
277 changed files with 21116 additions and 1797 deletions

View File

@ -1,7 +0,0 @@
Apache CloudStack is an effort undergoing incubation at The Apache Software Foundation (ASF),
sponsored by the Apache Incubator. Incubation is required of all newly accepted
projects until a further review indicates that the infrastructure, communications, and
decision making process have stabilized in a manner consistent with other successful ASF
projects. While incubation status is not necessarily a reflection of the completeness or
stability of the code, it does indicate that the project has yet to be fully endorsed by
the ASF.

View File

@ -19,6 +19,7 @@ package com.cloud.agent.api;
import com.cloud.agent.api.LogLevel.Log4jLevel;
import com.cloud.agent.api.to.S3TO;
import com.cloud.agent.api.to.SwiftTO;
import com.cloud.storage.StoragePool;
/**
* This command encapsulates a primitive operation which enables coalescing the backed up VHD snapshots on the secondary server
@ -78,7 +79,8 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
* @param backupUUID The VHD which has to be deleted
* @param childUUID The child VHD file of the backup whose parent is reset to its grandparent.
*/
public DeleteSnapshotBackupCommand(SwiftTO swift,
public DeleteSnapshotBackupCommand(StoragePool pool,
SwiftTO swift,
S3TO s3,
String secondaryStoragePoolURL,
Long dcId,
@ -86,7 +88,7 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
Long volumeId,
String backupUUID, Boolean all)
{
super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
super(pool, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
setSwift(swift);
this.s3 = s3;
setAll(all);

View File

@ -49,7 +49,8 @@ public interface AsyncJob extends Identity, InternalIdentity {
AutoScalePolicy,
AutoScaleVmProfile,
AutoScaleVmGroup,
GlobalLoadBalancerRule
GlobalLoadBalancerRule,
AffinityGroup
}
long getUserId();

View File

@ -35,7 +35,9 @@ import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
@ -234,6 +236,10 @@ public interface ConfigurationService {
boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd);
Vlan dedicatePublicIpRange(DedicatePublicIpRangeCmd cmd) throws ResourceAllocationException;
boolean releasePublicIpRange(ReleasePublicIpRangeCmd cmd);
NetworkOffering createNetworkOffering(CreateNetworkOfferingCmd cmd);
NetworkOffering updateNetworkOffering(UpdateNetworkOfferingCmd cmd);

View File

@ -226,6 +226,8 @@ public class EventTypes {
// VLANs/IP ranges
public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
public static final String EVENT_VLAN_IP_RANGE_DEDICATE = "VLAN.IP.RANGE.DEDICATE";
public static final String EVENT_VLAN_IP_RANGE_RELEASE = "VLAN.IP.RANGE.RELEASE";
public static final String EVENT_STORAGE_IP_RANGE_CREATE = "STORAGE.IP.RANGE.CREATE";
public static final String EVENT_STORAGE_IP_RANGE_DELETE = "STORAGE.IP.RANGE.DELETE";
@ -348,7 +350,7 @@ public class EventTypes {
// tag related events
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
// vm snapshot events
public static final String EVENT_VM_SNAPSHOT_CREATE = "VMSNAPSHOT.CREATE";
public static final String EVENT_VM_SNAPSHOT_DELETE = "VMSNAPSHOT.DELETE";
@ -382,6 +384,12 @@ public class EventTypes {
public static final String EVENT_BAREMETAL_PXE_SERVER_ADD = "PHYSICAL.PXE.ADD";
public static final String EVENT_BAREMETAL_PXE_SERVER_DELETE = "PHYSICAL.PXE.DELETE";
public static final String EVENT_AFFINITY_GROUP_CREATE = "AG.CREATE";
public static final String EVENT_AFFINITY_GROUP_DELETE = "AG.DELETE";
public static final String EVENT_AFFINITY_GROUP_ASSIGN = "AG.ASSIGN";
public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE";
public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@ -539,6 +547,8 @@ public class EventTypes {
// VLANs/IP ranges
entityEventDetails.put(EVENT_VLAN_IP_RANGE_CREATE, Vlan.class.getName());
entityEventDetails.put(EVENT_VLAN_IP_RANGE_DELETE,Vlan.class.getName());
entityEventDetails.put(EVENT_VLAN_IP_RANGE_DEDICATE, Vlan.class.getName());
entityEventDetails.put(EVENT_VLAN_IP_RANGE_RELEASE,Vlan.class.getName());
entityEventDetails.put(EVENT_STORAGE_IP_RANGE_CREATE, StorageNetworkIpRange.class.getName());
entityEventDetails.put(EVENT_STORAGE_IP_RANGE_DELETE, StorageNetworkIpRange.class.getName());

View File

@ -0,0 +1,34 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.exception;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.CloudRuntimeException;
public class AffinityConflictException extends CloudRuntimeException {
private static final long serialVersionUID = SerialVersionUID.AffinityConflictException;
public AffinityConflictException(String message) {
super(message);
}
public AffinityConflictException(String message, Throwable th) {
super(message, th);
}
}

View File

@ -16,24 +16,11 @@
// under the License.
package com.cloud.network;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@ -137,6 +124,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Provider None = new Provider("None", false);
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true);
private String name;
private boolean isExternal;
@ -182,6 +170,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification");
public static final Capability RedundantRouter = new Capability("RedundantRouter");
public static final Capability ElasticIp = new Capability("ElasticIp");
public static final Capability AssociatePublicIP = new Capability("AssociatePublicIP");
public static final Capability ElasticLb = new Capability("ElasticLb");
public static final Capability AutoScaleCounters = new Capability("AutoScaleCounters");
public static final Capability InlineMode = new Capability("InlineMode");

View File

@ -46,7 +46,7 @@ public interface NetworkService {
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException,
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException,
InsufficientAddressCapacityException, ConcurrentOperationException;
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;

View File

@ -107,6 +107,8 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean getElasticIp();
boolean getAssociatePublicIP();
boolean getElasticLb();
boolean getSpecifyIpRanges();

View File

@ -123,7 +123,7 @@ public interface ManagementService {
/**
* Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
* "podId"
*
*
* @param cmd
* @return List of Hosts
*/
@ -407,4 +407,6 @@ public interface ManagementService {
*/
List<? extends Capacity> listTopConsumedResources(ListCapacityCmd cmd);
List<String> listDeploymentPlanners();
}

View File

@ -139,7 +139,7 @@ public class DiskProfile {
this.hyperType = hyperType;
}
public HypervisorType getHypersorType() {
public HypervisorType getHypervisorType() {
return this.hyperType;
}

View File

@ -26,9 +26,6 @@ import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
import org.apache.cloudstack.api.command.user.vm.*;
import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
import com.cloud.dc.DataCenter;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@ -42,7 +39,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.IpAddresses;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
@ -104,14 +100,14 @@ public interface UserVmService {
* @return the vm object if successful, null otherwise
*/
UserVm addNicToVirtualMachine(AddNicToVMCmd cmd);
/**
* Removes a NIC on the given network from the virtual machine
* @param cmd the command object that defines the vm and the given network
* @return the vm object if successful, null otherwise
*/
UserVm removeNicFromVirtualMachine(RemoveNicFromVMCmd cmd);
/**
* Updates default Nic to the given network for given virtual machine
* @param cmd the command object that defines the vm and the given network
@ -123,7 +119,8 @@ public interface UserVmService {
/**
* Creates a Basic Zone User VM in the database and returns the VM to the caller.
* Creates a Basic Zone User VM in the database and returns the VM to the
* caller.
*
* @param zone
* - availability zone for the virtual machine
@ -132,61 +129,69 @@ public interface UserVmService {
* @param template
* - the template for the virtual machine
* @param securityGroupIdList
* - comma separated list of security groups id that going to be applied to the virtual machine
* - comma separated list of security groups id that going to be
* applied to the virtual machine
* @param hostName
* - host name for the virtual machine
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
* diskOfferingId is
* for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
* volume.
* If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
* Volume
* created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
* Disk
* Volume created
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
* binary
* data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
* Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIp
* TODO
* @param affinityGroupIdList
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
* be used
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the same environment.
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently available.
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, String keyboard)
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp,
String keyboard, List<Long> affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
* Creates a User VM in Advanced Zone (Security Group feature is enabled) in the database and returns the VM to the
* caller.
* Creates a User VM in Advanced Zone (Security Group feature is enabled) in
* the database and returns the VM to the caller.
*
* @param zone
* - availability zone for the virtual machine
@ -197,63 +202,69 @@ public interface UserVmService {
* @param networkIdList
* - list of network ids used by virtual machine
* @param securityGroupIdList
* - comma separated list of security groups id that going to be applied to the virtual machine
* - comma separated list of security groups id that going to be
* applied to the virtual machine
* @param hostName
* - host name for the virtual machine
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
* diskOfferingId is
* for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
* volume.
* If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
* Volume
* created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
* Disk
* Volume created
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
* binary
* data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
* Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIps
* TODO
* @param affinityGroupIdList
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
* be used
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the same environment.
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently available.
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList,
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
IpAddresses defaultIps, String keyboard)
IpAddresses defaultIps, String keyboard, List<Long> affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
* Creates a User VM in Advanced Zone (Security Group feature is disabled) in the database and returns the VM to the
* caller.
*
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
* in the database and returns the VM to the caller.
*
* @param zone
* - availability zone for the virtual machine
* @param serviceOffering
@ -267,49 +278,57 @@ public interface UserVmService {
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
* diskOfferingId is
* for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
* volume.
* If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
* Volume
* created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
* Disk
* Volume created
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
* binary
* data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
* Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIps TODO
* @param defaultIps
* TODO
* @param affinityGroupIdList
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
* be used
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the same environment.
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently available.
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps,
String keyboard, List<Long> affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**

View File

@ -0,0 +1,31 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.affinity;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface AffinityGroup extends ControlledEntity, InternalIdentity, Identity {
String getName();
String getDescription();
String getType();
}

View File

@ -0,0 +1,49 @@
// 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.affinity;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AffinityConflictException;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
public interface AffinityGroupProcessor extends Adapter {
/**
* process() is called to apply any user preferences to the deployment plan
* and avoid set for the given VM placement.
*
* @param vm
* virtual machine.
* @param plan
* deployment plan that tells you where it's being deployed to.
* @param avoid
* avoid these data centers, pods, clusters, or hosts.
*/
void process(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid)
throws AffinityConflictException;
/**
* getType() should return the affinity/anti-affinity group being
* implemented
*
* @return String Affinity/Anti-affinity type
*/
String getType();
}

View File

@ -0,0 +1,155 @@
// 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.affinity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import org.apache.cloudstack.api.response.ControlledEntityResponse;
import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import com.cloud.network.security.SecurityGroup;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
@EntityReference(value = AffinityGroup.class)
public class AffinityGroupResponse extends BaseResponse implements ControlledViewEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the affinity group")
private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the affinity group")
private String name;
@SerializedName(ApiConstants.DESCRIPTION) @Param(description="the description of the affinity group")
private String description;
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account owning the affinity group")
private String accountName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the affinity group")
private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the affinity group")
private String domainName;
@SerializedName(ApiConstants.TYPE)
@Param(description = "the type of the affinity group")
private String type;
@SerializedName("virtualmachineIds")
@Param(description = "virtual machine Ids associated with this affinity group ")
private List<String> vmIdList;
public AffinityGroupResponse() {
this.vmIdList = new ArrayList<String>();
}
@Override
public String getObjectId() {
return this.getId();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setType(String type) {
this.type = type;
}
@Override
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AffinityGroupResponse other = (AffinityGroupResponse) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@Override
public void setProjectId(String projectId) {
// TODO Auto-generated method stub
}
@Override
public void setProjectName(String projectName) {
// TODO Auto-generated method stub
}
public void setVMIdList(List<String> vmIdList) {
this.vmIdList = vmIdList;
}
public void addVMId(String vmId) {
this.vmIdList.add(vmId);
}
}

View File

@ -0,0 +1,79 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.affinity;
import java.util.List;
import com.cloud.exception.ResourceInUseException;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
public interface AffinityGroupService {
/**
* Creates an affinity/anti-affinity group for the given account/domain.
*
* @param account
* @param domainId
* @param name
* @param type
* @param description
* @return AffinityGroup
*/
AffinityGroup createAffinityGroup(String account, Long domainId, String affinityGroupName,
String affinityGroupType, String description);
/**
* Creates an affinity/anti-affinity group.
*
* @param affinityGroupId
* @param account
* @param domainId
* @param affinityGroupName
* @throws ResourceInUseException
*/
boolean deleteAffinityGroup(Long affinityGroupId, String account, Long domainId, String affinityGroupName)
throws ResourceInUseException;
/** Lists Affinity Groups in your account
* @param account
* @param domainId
* @param affinityGroupId
* @param affinityGroupName
* @param affinityGroupType
* @param vmId
* @param startIndex
* @param pageSize
* @return
*/
Pair<List<? extends AffinityGroup>, Integer> listAffinityGroups(Long affinityGroupId, String affinityGroupName,
String affinityGroupType, Long vmId, Long startIndex, Long pageSize);
/**
* List group types available in deployment
*
* @return
*/
List<String> listAffinityGroupTypes();
AffinityGroup getAffinityGroup(Long groupId);
UserVm updateVMAffinityGroups(Long vmId, List<Long> affinityGroupIds);
}

View File

@ -0,0 +1,48 @@
// 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.affinity;
import java.util.HashSet;
import java.util.Set;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import org.apache.cloudstack.api.response.ControlledEntityResponse;
import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
import com.cloud.network.security.SecurityGroup;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
@EntityReference(value = AffinityGroup.class)
public class AffinityGroupTypeResponse extends BaseResponse {
@SerializedName(ApiConstants.TYPE)
@Param(description = "the type of the affinity group")
private String type;
public AffinityGroupTypeResponse() {
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,44 @@
// 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.affinity;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AffinityConflictException;
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
public class AffinityProcessorBase extends AdapterBase implements AffinityGroupProcessor {
protected String _type;
@Override
public void process(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid)
throws AffinityConflictException {
}
@Override
public String getType() {
return _type;
}
public void setType(String type) {
_type = type;
}
}

View File

@ -473,13 +473,17 @@ public class ApiConstants {
public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold";
public static final String HEALTHCHECK_UNHEALTHY_THRESHOLD = "unhealthythreshold";
public static final String HEALTHCHECK_PINGPATH = "pingpath";
public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
public static final String DEPLOYMENT_PLANNER = "deploymentplanner";
public static final String ASA_INSIDE_PORT_PROFILE = "insideportprofile";
public enum HostDetails {
all, capacity, events, stats, min;
}
public enum VMDetails {
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min;
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min, affgrp;
}
public enum LDAPParams {

View File

@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.query.QueryService;
import org.apache.cloudstack.usage.UsageService;
import org.apache.log4j.Logger;
@ -132,6 +133,7 @@ public abstract class BaseCmd {
@Inject public VMSnapshotService _vmSnapshotService;
@Inject public DataStoreProviderApiService dataStoreProviderApiService;
@Inject public VpcProvisioningService _vpcProvSvc;
@Inject public AffinityGroupService _affinityGroupService;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
@ -154,7 +156,7 @@ public abstract class BaseCmd {
/**
* For commands the API framework needs to know the owner of the object being acted upon. This method is
* used to determine that information.
*
*
* @return the id of the account that owns the object being acted upon
*/
public abstract long getEntityOwnerId();
@ -467,7 +469,7 @@ public abstract class BaseCmd {
if (!enabledOnly || account.getState() == Account.State.enabled) {
return account.getId();
} else {
throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
}
} else {
// idList is not used anywhere, so removed it now
@ -484,7 +486,7 @@ public abstract class BaseCmd {
return project.getProjectAccountId();
} else {
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
ex.addProxyObject(project, projectId, "projectId");
ex.addProxyObject(project, projectId, "projectId");
throw ex;
}
} else {

View File

@ -20,6 +20,8 @@ import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
@ -150,18 +152,9 @@ 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.snapshot.VMSnapshot;
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
import org.apache.cloudstack.api.response.*;
import org.apache.cloudstack.region.Region;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
public interface ResponseGenerator {
UserResponse createUserResponse(UserAccount user);
@ -384,12 +377,17 @@ public interface ResponseGenerator {
GuestOSResponse createGuestOSResponse(GuestOS os);
SnapshotScheduleResponse createSnapshotScheduleResponse(SnapshotSchedule sched);
UsageRecordResponse createUsageResponse(Usage usageRecord);
TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
NicSecondaryIpResponse createSecondaryIPToNicResponse(String ip,
Long nicId, Long networkId);
public NicResponse createNicResponse(Nic result);
AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group);
Long getAffinityGroupId(String name, long entityOwnerId);
}

View File

@ -111,14 +111,14 @@ public class UpdateClusterCmd extends BaseCmd {
if(cpuovercommitratio != null){
return Float.parseFloat(cpuovercommitratio);
}
return 1.0f;
return null;
}
public Float getMemoryOvercommitRaito (){
if (memoryovercommitratio != null){
return Float.parseFloat(memoryovercommitratio);
}
return 1.0f;
return null;
}
@Override
@ -127,9 +127,16 @@ public class UpdateClusterCmd extends BaseCmd {
if (cluster == null) {
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
}
if (getMemoryOvercommitRaito() !=null){
if ((getMemoryOvercommitRaito().compareTo(1f) < 0)) {
throw new InvalidParameterValueException("Memory overcommit ratio should be greater than or equal to one");
}
}
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one");
if (getCpuOvercommitRatio() !=null){
if (getCpuOvercommitRatio().compareTo(1f) < 0) {
throw new InvalidParameterValueException("Cpu overcommit ratio should be greater than or equal to one");
}
}
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio());

View File

@ -0,0 +1,71 @@
// 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.config;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.DeploymentPlannersResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.log4j.Logger;
@APICommand(name = "listDeploymentPlanners", description = "Lists all DeploymentPlanners available.", responseObject = DeploymentPlannersResponse.class)
public class ListDeploymentPlannersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDeploymentPlannersCmd.class.getName());
private static final String s_name = "listdeploymentplannersresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
List<String> planners = _mgr.listDeploymentPlanners();
ListResponse<DeploymentPlannersResponse> response = new ListResponse<DeploymentPlannersResponse>();
List<DeploymentPlannersResponse> plannerResponses = new ArrayList<DeploymentPlannersResponse>();
for (String planner : planners) {
DeploymentPlannersResponse plannerResponse = new DeploymentPlannersResponse();
plannerResponse.setName(planner);
plannerResponse.setObjectName("deploymentPlanner");
plannerResponses.add(plannerResponse);
}
response.setResponses(plannerResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -84,6 +84,9 @@ public class CreateServiceOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed. Supported only for non-System offering and system offerings having \"domainrouter\" systemvmtype")
private Integer networkRate;
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "The deployment planner heuristics used to deploy a VM of this offering, default \"FirstFitPlanner\".")
private String deploymentPlanner;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -148,6 +151,10 @@ public class CreateServiceOfferingCmd extends BaseCmd {
return networkRate;
}
public String getDeploymentPlanner() {
return deploymentPlanner;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,108 @@
// 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.vlan;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.dc.Vlan;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@APICommand(name = "dedicatePublicIpRange", description="Dedicates a Public IP range to an account", responseObject=VlanIpRangeResponse.class)
public class DedicatePublicIpRangeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DedicatePublicIpRangeCmd.class.getName());
private static final String s_name = "dedicatepubliciprangeresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VlanIpRangeResponse.class,
required=true, description="the id of the VLAN IP range")
private Long id;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true,
description="account who will own the VLAN")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
description="project who will own the VLAN")
private Long projectId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
required=true, description="domain ID of the account owning a VLAN")
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
Vlan result = _configService.dedicatePublicIpRange(this);
if (result != null) {
VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate vlan ip range");
}
}
}

View File

@ -0,0 +1,77 @@
// 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.vlan;
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.SuccessResponse;
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@APICommand(name = "releasePublicIpRange", description="Releases a Public IP range back to the system pool", responseObject=SuccessResponse.class)
public class ReleasePublicIpRangeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ReleasePublicIpRangeCmd.class.getName());
private static final String s_name = "releasepubliciprangeresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VlanIpRangeResponse.class,
required=true, description="the id of the Public IP range")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
boolean result = _configService.releasePublicIpRange(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release public ip range");
}
}
}

View File

@ -16,38 +16,21 @@
// under the License.
package org.apache.cloudstack.api.command.user.address;
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.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.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.exception.*;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.*;
import org.apache.log4j.Logger;
import java.util.List;
@APICommand(name = "associateIpAddress", description="Acquires and associates a public IP to an account.", responseObject=IPAddressResponse.class)
public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@ -213,7 +196,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException{
try {
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), false, getZoneId());
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId());
if (ip != null) {
this.setEntityId(ip.getId());

View File

@ -0,0 +1,167 @@
// 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.affinitygroup;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@APICommand(name = "createAffinityGroup", responseObject = AffinityGroupResponse.class, description = "Creates an affinity/anti-affinity group")
public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
public static final Logger s_logger = Logger.getLogger(CreateAffinityGroupCmd.class.getName());
private static final String s_name = "createaffinitygroupresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the affinity group. Must be used with domainId.")
private String accountName;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the affinity group", entityType = DomainResponse.class)
private Long domainId;
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the affinity group")
private String description;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the affinity group")
private String affinityGroupName;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, description = "Type of the affinity group from the available affinity/anti-affinity group types")
private String affinityGroupType;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public String getAccountName() {
return accountName;
}
public String getDescription() {
return description;
}
public Long getDomainId() {
return domainId;
}
public String getAffinityGroupName() {
return affinityGroupName;
}
public String getAffinityGroupType() {
return affinityGroupType;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this
// command to SYSTEM so ERROR events
// are tracked
}
@Override
public void execute() {
AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
if (group != null) {
AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group:"
+ affinityGroupName);
}
}
@Override
public void create() throws ResourceAllocationException {
AffinityGroup result = _affinityGroupService.createAffinityGroup(accountName, domainId, affinityGroupName,
affinityGroupType, description);
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group entity" + affinityGroupName);
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_AFFINITY_GROUP_CREATE;
}
@Override
public String getEventDescription() {
return "creating Affinity Group";
}
@Override
public String getCreateEventType() {
return EventTypes.EVENT_AFFINITY_GROUP_CREATE;
}
@Override
public String getCreateEventDescription() {
return "creating Affinity Group";
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.AffinityGroup;
}
}

View File

@ -0,0 +1,154 @@
// 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.affinitygroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
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.DomainResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@APICommand(name = "deleteAffinityGroup", description = "Deletes affinity group", responseObject = SuccessResponse.class)
public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteAffinityGroupCmd.class.getName());
private static final String s_name = "deleteaffinitygroupresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account of the affinity group. Must be specified with domain ID")
private String accountName;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "the domain ID of account owning the affinity group", entityType = DomainResponse.class)
private Long domainId;
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the affinity group. Mutually exclusive with name parameter", entityType = AffinityGroupResponse.class)
private Long id;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the affinity group. Mutually exclusive with id parameter")
private String name;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
public Long getId() {
if (id != null && name != null) {
throw new InvalidParameterValueException("name and id parameters are mutually exclusive");
}
if (name != null) {
id = _responseGenerator.getAffinityGroupId(name, getEntityOwnerId());
if (id == null) {
throw new InvalidParameterValueException("Unable to find affinity group by name " + name
+ " for the account id=" + getEntityOwnerId());
}
}
if (id == null) {
throw new InvalidParameterValueException(
"Either id or name parameter is requred by deleteAffinityGroup command");
}
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this
// command to SYSTEM so ERROR events
// are tracked
}
@Override
public void execute(){
try{
boolean result = _affinityGroupService.deleteAffinityGroup(id, accountName, domainId, name);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete affinity group");
}
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_AFFINITY_GROUP_DELETE;
}
@Override
public String getEventDescription() {
return "Deleting Affinity Group";
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.AffinityGroup;
}
}

View File

@ -0,0 +1,67 @@
// 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.affinitygroup;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.affinity.AffinityGroupTypeResponse;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@APICommand(name = "listAffinityGroupTypes", description = "Lists affinity group types available", responseObject = AffinityGroupTypeResponse.class)
public class ListAffinityGroupTypesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListAffinityGroupTypesCmd.class.getName());
private static final String s_name = "listaffinitygrouptypesresponse";
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
List<String> result = _affinityGroupService.listAffinityGroupTypes();
ListResponse<AffinityGroupTypeResponse> response = new ListResponse<AffinityGroupTypeResponse>();
ArrayList<AffinityGroupTypeResponse> responses = new ArrayList<AffinityGroupTypeResponse>();
if (result != null) {
for (String type : result) {
AffinityGroupTypeResponse affinityTypeResponse = new AffinityGroupTypeResponse();
affinityTypeResponse.setType(type);
affinityTypeResponse.setObjectName("affinityGroupType");
responses.add(affinityTypeResponse);
}
}
response.setResponses(responses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -0,0 +1,90 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.affinitygroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
@APICommand(name = "listAffinityGroups", description = "Lists affinity groups", responseObject = AffinityGroupResponse.class)
public class ListAffinityGroupsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListAffinityGroupsCmd.class.getName());
private static final String s_name = "listaffinitygroupsresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists affinity groups by name")
private String affinityGroupName;
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, description = "lists affinity groups by virtual machine id", entityType = UserVmResponse.class)
private Long virtualMachineId;
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the affinity group by the id provided", entityType = AffinityGroupResponse.class)
private Long id;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "lists affinity groups by type")
private String affinityGroupType;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getAffinityGroupName() {
return affinityGroupName;
}
public Long getVirtualMachineId() {
return virtualMachineId;
}
public Long getId(){
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
ListResponse<AffinityGroupResponse> response = _queryService.listAffinityGroups(id, affinityGroupName,
affinityGroupType, virtualMachineId, this.getStartIndex(), this.getPageSizeVal());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.AffinityGroup;
}
}

View File

@ -0,0 +1,164 @@
// 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.affinitygroup;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ACL;
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.ApiConstants.VMDetails;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
@APICommand(name = "updateVMAffinityGroup", description = "Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the "
+ "new properties to take effect.", responseObject = UserVmResponse.class)
public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(UpdateVMAffinityGroupCmd.class.getName());
private static final String s_name = "updatevirtualmachineresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@ACL
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
required=true, description="The ID of the virtual machine")
private Long id;
@ACL
@Parameter(name = ApiConstants.AFFINITY_GROUP_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups id that are going to be applied to the virtual machine. "
+ "Should be passed only when vm is created from a zone with Basic Network support."
+ " Mutually exclusive with securitygroupnames parameter")
private List<Long> affinityGroupIdList;
@ACL
@Parameter(name = ApiConstants.AFFINITY_GROUP_NAMES, type = CommandType.LIST, collectionType = CommandType.STRING, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups names that are going to be applied to the virtual machine."
+ " Should be passed only when vm is created from a zone with Basic Network support. "
+ "Mutually exclusive with securitygroupids parameter")
private List<String> affinityGroupNameList;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public List<Long> getAffinityGroupIdList() {
if (affinityGroupNameList != null && affinityGroupIdList != null) {
throw new InvalidParameterValueException(
"affinitygroupids parameter is mutually exclusive with affinitygroupnames parameter");
}
// transform group names to ids here
if (affinityGroupNameList != null) {
List<Long> affinityGroupIds = new ArrayList<Long>();
for (String groupName : affinityGroupNameList) {
Long groupId = _responseGenerator.getAffinityGroupId(groupName, getEntityOwnerId());
if (groupId == null) {
throw new InvalidParameterValueException("Unable to find group by name " + groupName
+ " for account " + getEntityOwnerId());
} else {
affinityGroupIds.add(groupId);
}
}
return affinityGroupIds;
} else {
return affinityGroupIdList;
}
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public static String getResultObjectName() {
return "virtualmachine";
}
@Override
public long getEntityOwnerId() {
UserVm userVm = _entityMgr.findById(UserVm.class, getId());
if (userVm != null) {
return userVm.getAccountId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException {
UserContext.current().setEventDetails("Vm Id: "+getId());
UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList());
ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
dc.add(VMDetails.valueOf("affgrp"));
EnumSet<VMDetails> details = EnumSet.copyOf(dc);
if (result != null){
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups");
}
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_AFFINITY_GROUP_UPDATE;
}
@Override
public String getEventDescription() {
return "updating VM Affinity Group";
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.AffinityGroup;
}
}

View File

@ -93,6 +93,9 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
}
public String getStickyMethod() {
if (stickyMethod == null) {
return "sourceip";
}
return stickyMethod;
}

View File

@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -172,6 +173,16 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.START_VM, type=CommandType.BOOLEAN, description="true if network offering supports specifying ip ranges; defaulted to true if not specified")
private Boolean startVm;
@ACL
@Parameter(name = ApiConstants.AFFINITY_GROUP_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups id that are going to be applied to the virtual machine."
+ " Mutually exclusive with affinitygroupnames parameter")
private List<Long> affinityGroupIdList;
@ACL
@Parameter(name = ApiConstants.AFFINITY_GROUP_NAMES, type = CommandType.LIST, collectionType = CommandType.STRING, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups names that are going to be applied to the virtual machine."
+ "Mutually exclusive with affinitygroupids parameter")
private List<String> affinityGroupNameList;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -321,6 +332,30 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
return ip6Address.toLowerCase();
}
public List<Long> getAffinityGroupIdList() {
if (affinityGroupNameList != null && affinityGroupIdList != null) {
throw new InvalidParameterValueException(
"affinitygroupids parameter is mutually exclusive with affinitygroupnames parameter");
}
// transform group names to ids here
if (affinityGroupNameList != null) {
List<Long> affinityGroupIds = new ArrayList<Long>();
for (String groupName : affinityGroupNameList) {
Long groupId = _responseGenerator.getAffinityGroupId(groupName, getEntityOwnerId());
if (groupId == null) {
throw new InvalidParameterValueException("Unable to find group by name " + groupName
+ " for account " + getEntityOwnerId());
} else {
affinityGroupIds.add(groupId);
}
}
return affinityGroupIds;
} else {
return affinityGroupIdList;
}
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -447,18 +482,18 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
} else {
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
}
} else {
if (zone.isSecurityGroupEnabled()) {
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
} else {
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
}
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
}
}

View File

@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.response;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class DeploymentPlannersResponse extends BaseResponse {
@SerializedName(ApiConstants.NAME)
@Param(description = "Deployment Planner name")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -50,6 +50,10 @@ public class GlobalLoadBalancerResponse extends BaseResponse implements Controll
@Param(description = "session persistence method used for the global load balancer")
private String stickyMethod;
@SerializedName(ApiConstants.GSLB_SERVICE_TYPE)
@Param(description = "GSLB service type")
private String serviceType;
@SerializedName(ApiConstants.REGION_ID)
@Param(description = "Region Id in which global load balancer is created")
private Integer regionId;
@ -96,6 +100,10 @@ public class GlobalLoadBalancerResponse extends BaseResponse implements Controll
this.stickyMethod = stickyMethod;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public void setServiceDomainName(String domainName) {
this.gslbDomainName = domainName;
}

View File

@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
@ -169,10 +170,15 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.SSH_KEYPAIR) @Param(description="ssh key-pair")
private String keyPairName;
@SerializedName("affinitygroup")
@Param(description = "list of affinity groups associated with the virtual machine", responseObject = AffinityGroupResponse.class)
private Set<AffinityGroupResponse> affinityGroupList;
public UserVmResponse(){
securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
nics = new LinkedHashSet<NicResponse>();
tags = new LinkedHashSet<ResourceTagResponse>();
affinityGroupList = new LinkedHashSet<AffinityGroupResponse>();
}
public void setHypervisor(String hypervisor) {
@ -381,4 +387,12 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
this.keyPairName = keyPairName;
}
public void setAffinityGroupList(Set<AffinityGroupResponse> affinityGroups) {
this.affinityGroupList = affinityGroups;
}
public void addAffinityGroup(AffinityGroupResponse affinityGroup) {
this.affinityGroupList.add(affinityGroup);
}
}

View File

@ -43,6 +43,7 @@ public interface ExternalNetworkDeviceManager extends Manager {
public static final NetworkDevice F5BigIpLoadBalancer = new NetworkDevice("F5BigIpLoadBalancer", Network.Provider.F5BigIp.getName());
public static final NetworkDevice JuniperSRXFirewall = new NetworkDevice("JuniperSRXFirewall", Network.Provider.JuniperSRX.getName());
public static final NetworkDevice NiciraNvp = new NetworkDevice("NiciraNvp", Network.Provider.NiciraNvp.getName());
public static final NetworkDevice CiscoVnmc = new NetworkDevice("CiscoVnmc", Network.Provider.CiscoVnmc.getName());
public NetworkDevice(String deviceName, String ntwkServiceprovider) {
_name = deviceName;

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.query;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
@ -97,4 +98,7 @@ public interface QueryService {
public ListResponse<ServiceOfferingResponse> searchForServiceOfferings(ListServiceOfferingsCmd cmd);
public ListResponse<ZoneResponse> listDataCenters(ListZonesByCmd cmd);
public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId, String affinityGroupName,
String affinityGroupType, Long vmId, Long startIndex, Long pageSize);
}

View File

@ -209,7 +209,7 @@ public class EC2RestServlet extends HttpServlet {
if (installedPath == null) installedPath = System.getProperty("catalina.home");
String webappPath = config.getServletContext().getRealPath("/");
//pathToKeystore = new String( installedPath + File.separator + "webapps" + File.separator + webappName + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + keystore );
pathToKeystore = new String( webappPath + File.separator + "\\WEB-INF" + File.separator + "classes" + File.separator + keystore );
pathToKeystore = new String( webappPath + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + keystore );
}
}

View File

@ -27,3 +27,4 @@ MSMNTDIR=/mnt
COMPONENTS-SPEC=components.xml
AWSAPILOG=awsapi.log
REMOTEHOST=localhost
COMMONLIBDIR=C:\Users\htrippaers\eclipse_workspace\cloudstack\client\target\cloud-client-ui-4.2.0-SNAPSHOT\WEB-INF\classes

View File

@ -234,6 +234,11 @@
<artifactId>cloud-plugin-snmp-alerts</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-host-anti-affinity</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
@ -284,7 +289,7 @@
-->
<execution>
<id>copy-systemvm</id>
<phase>package</phase>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
@ -450,6 +455,11 @@
file="${basedir}/target/generated-webapp/WEB-INF/web.xml"
match="classpath:componentContext.xml"
replace="classpath:nonossComponentContext.xml" byline="true" />
<exec executable="cp">
<arg value="-r" />
<arg value="${basedir}/../plugins/network-elements/cisco-vnmc/scripts" />
<arg value="${basedir}/target/generated-webapp/WEB-INF/classes/" />
</exec>
</target>
</configuration>
</execution>
@ -634,6 +644,11 @@
<artifactId>cloud-vmware-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-network-cisco-vnmc</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>

View File

@ -454,11 +454,11 @@
<property name="name" value="Balance"/>
</bean>
<bean id="ExteralIpAddressAllocator" class="com.cloud.network.ExteralIpAddressAllocator">
<bean id="ExternalIpAddressAllocator" class="com.cloud.network.ExternalIpAddressAllocator">
<property name="name" value="Basic"/>
</bean>
<bean id="hyervisorTemplateAdapter" class="com.cloud.template.HypervisorTemplateAdapter" />
<bean id="hypervisorTemplateAdapter" class="com.cloud.template.HypervisorTemplateAdapter" />
<bean id="clusterAlertAdapter" class="com.cloud.alert.ClusterAlertAdapter" />
<bean id="consoleProxyAlertAdapter" class="com.cloud.alert.ConsoleProxyAlertAdapter" />
<bean id="secondaryStorageVmAlertAdapter" class="com.cloud.alert.SecondaryStorageVmAlertAdapter" />
@ -609,8 +609,10 @@
<property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
<property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
<property name="HostAllocators" value="#{hostAllocators.Adapters}" />
<property name="Planners" value="#{deploymentPlanners.Adapters}" />
<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
</bean>
<bean id="storageManagerImpl" class="com.cloud.storage.StorageManagerImpl">
<property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
</bean>
@ -733,7 +735,7 @@
<bean id="defaultEndPointSelector" class="org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector" />
<bean id="defaultPrimaryDataStoreProviderManagerImpl" class="org.apache.cloudstack.storage.datastore.manager.DefaultPrimaryDataStoreProviderManagerImpl" />
<bean id="eventUtils" class="com.cloud.event.EventUtils" />
<bean id="hypervsiorHostEndPointRpcServer" class="org.apache.cloudstack.storage.HypervsiorHostEndPointRpcServer" />
<bean id="hypervisorHostEndPointRpcServer" class="org.apache.cloudstack.storage.HypervisorHostEndPointRpcServer" />
<bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
<bean id="imageDataFactoryImpl" class="org.apache.cloudstack.storage.image.ImageDataFactoryImpl" />
@ -836,5 +838,18 @@
<bean id="baremetalDhcpDaoImpl" class="com.cloud.baremetal.database.BaremetalDhcpDaoImpl" />
<bean id="baremetalPxeDaoImpl" class="com.cloud.baremetal.database.BaremetalPxeDaoImpl" />
-->
<bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl"/>
<bean id="DeploymentPlanningManager" class="com.cloud.deploy.DeploymentPlanningManagerImpl">
<property name="Planners" value="#{deploymentPlanners.Adapters}" />
<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
</bean>
<bean id="AffinityGroupJoinDaoImpl" class="com.cloud.api.query.dao.AffinityGroupJoinDaoImpl">
</bean>
<bean id="AffinityGroupDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl">
</bean>
<bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl">
</bean>
</beans>

View File

@ -124,6 +124,8 @@ listDiskOfferings=15
createVlanIpRange=1
deleteVlanIpRange=1
listVlanIpRanges=1
dedicatePublicIpRange=1
releasePublicIpRange=1
#### address commands
associateIpAddress=15
@ -568,3 +570,21 @@ revertToSnapshot=15
#### Baremetal commands
addBaremetalHost=1
#### Affinity group commands
createAffinityGroup=15
deleteAffinityGroup=15
listAffinityGroups=15
updateVMAffinityGroup=15
listAffinityGroupTypes=15
#### Cisco Vnmc commands
addCiscoVnmcResource=1
deleteCiscoVnmcResource=1
listCiscoVnmcResources=1
#### Cisco Asa1000v commands
addCiscoAsa1000vResource=1
deleteCiscoAsa1000vResource=1
listCiscoAsa1000vResources=1

View File

@ -31,6 +31,7 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!--
OSS deployment configuration
@ -155,7 +156,6 @@
<ref bean="FirstFitPlanner" />
<ref bean="UserDispersingPlanner" />
<ref bean="UserConcentratedPodPlanner" />
<!--
<ref bean="BareMetalPlanner" />
-->
@ -197,6 +197,7 @@
<ref bean="elasticLoadBalancerElement"/>
<ref bean="VirtualRouter"/>
<ref bean="VpcVirtualRouter"/>
<ref bean="NiciraNvp"/>
</list>
</property>
</bean>
@ -249,5 +250,20 @@
</property>
</bean>
<!--
AffinityGroup Processors
-->
<bean id="HostAntiAffinityProcessor" class="org.apache.cloudstack.affinity.HostAntiAffinityProcessor">
<property name="name" value="HostAntiAffinityProcessor"/>
<property name="type" value="host anti-affinity"/>
</bean>
<bean id="affinityProcessors" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
<ref bean="HostAntiAffinityProcessor" />
</list>
</property>
</bean>
</beans>

View File

@ -136,6 +136,16 @@
<property name="name" value="CiscoNexus1000vVSM"/>
</bean>
<!--
Cisco VNMC support components
-->
<bean id="ciscoVnmcDaoImpl" class="com.cloud.network.dao.CiscoVnmcDaoImpl" />
<bean id="ciscoAsa1000vDaoImpl" class="com.cloud.network.dao.CiscoAsa1000vDaoImpl" />
<bean id="networkAsa1000vMapDaoImpl" class="com.cloud.network.dao.NetworkAsa1000vMapDaoImpl" />
<bean id="CiscoVNMC" class="com.cloud.network.element.CiscoVnmcElement">
<property name="name" value="CiscoVNMC"/>
</bean>
<!--
BigSwitch support components
-->
@ -283,6 +293,7 @@
<ref bean="elasticLoadBalancerElement"/>
<ref bean="VirtualRouter"/>
<ref bean="VpcVirtualRouter"/>
<ref bean="NiciraNvp"/>
</list>
</property>
</bean>
@ -324,6 +335,7 @@
<ref bean="Netscaler"/>
<ref bean="F5BigIP"/>
<ref bean="CiscoNexus1000vVSM"/>
<ref bean="CiscoVNMC"/>
<ref bean="NiciraNvp" />
<ref bean="MidoNetElement" />
<ref bean="bigSwitchVnsElement"/>
@ -339,5 +351,21 @@
</list>
</property>
</bean>
<!--
AffinityGroup Processors
-->
<bean id="HostAntiAffinityProcessor" class="org.apache.cloudstack.affinity.HostAntiAffinityProcessor">
<property name="name" value="HostAntiAffinityProcessor"/>
<property name="type" value="host anti-affinity"/>
</bean>
<bean id="affinityProcessors" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
<ref bean="HostAntiAffinityProcessor" />
</list>
</property>
</bean>
</beans>

View File

@ -1,4 +1,3 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
@ -34,8 +33,8 @@
<!--
OSS deployment component configuration
-->
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl" />
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker"/>
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl"/>
<!-- simulator components -->
<bean id="SimulatorSecondaryDiscoverer" class="com.cloud.resource.SimulatorSecondaryDiscoverer">
@ -122,9 +121,9 @@
<bean id="deploymentPlanners" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
<ref bean="FirstFitPlanner" />
<ref bean="UserDispersingPlanner" />
<ref bean="UserConcentratedPodPlanner" />
<ref bean="FirstFitPlanner"/>
<ref bean="UserDispersingPlanner"/>
<ref bean="UserConcentratedPodPlanner"/>
<!--
<ref bean="BareMetalPlanner" />
@ -215,6 +214,23 @@
</property>
</bean>
<bean id="GlobalLoadBalancingRulesServiceImpl" class ="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
<bean id="GlobalLoadBalancingRulesServiceImpl"
class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl"/>
<!--
AffinityGroup Processors
-->
<bean id="HostAntiAffinityProcessor" class="org.apache.cloudstack.affinity.HostAntiAffinityProcessor">
<property name="name" value="HostAntiAffinityProcessor"/>
<property name="type" value="host anti-affinity"/>
</bean>
<bean id="affinityProcessors" class="com.cloud.utils.component.AdapterList">
<property name="Adapters">
<list>
<ref bean="HostAntiAffinityProcessor" />
</list>
</property>
</bean>
</beans>

View File

@ -20,4 +20,5 @@ public interface VmDetailConstants {
public static final String KEYBOARD = "keyboard";
public static final String NIC_ADAPTER = "nicAdapter";
public static final String ROOK_DISK_CONTROLLER = "rootDiskController";
public static final String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
}

View File

@ -15,4 +15,12 @@
# specific language governing permissions and limitations
# under the License.
/var/log/cloudstack/awsapi
/etc/cloudstack/management/cloud-bridge.properties
/etc/cloudstack/management/commons-logging.properties
/etc/cloudstack/management/crypto.properties
/etc/cloudstack/management/xes.keystore
/etc/cloudstack/management/ec2-service.properties
/var/log/cloudstack/awsapi
/usr/bin/cloudstack-setup-bridge
/usr/bin/cloudstack-aws-api-register
/usr/share/cloudstack-bridge

20
debian/rules vendored
View File

@ -34,7 +34,7 @@ build: build-indep
build-indep: build-indep-stamp
build-indep-stamp: configure
mvn package -DskipTests -Dsystemvm \
mvn -Pawsapi package -DskipTests -Dsystemvm \
-Dcs.replace.properties=replace.properties.tmp
touch $@
@ -147,7 +147,25 @@ install:
install -D packaging/debian/init/cloud-usage $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-usage
# cloudstack-awsapi
mkdir $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/awsapi
mkdir $(DESTDIR)/var/log/$(PACKAGE)/awsapi
mkdir $(DESTDIR)/usr/share/$(PACKAGE)-bridge
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi
mkdir $(DESTDIR)/usr/share/$(PACKAGE)-bridge/setup
cp -r awsapi/target/cloud-awsapi-$(VERSION)-SNAPSHOT/* $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi
install -D awsapi-setup/setup/cloud-setup-bridge $(DESTDIR)/usr/bin/cloudstack-setup-bridge
install -D awsapi-setup/setup/cloudstack-aws-api-register $(DESTDIR)/usr/bin/cloudstack-aws-api-register
cp -r awsapi-setup/db/mysql/* $(DESTDIR)/usr/share/$(PACKAGE)-bridge/setup
for i in applicationContext.xml cloud-bridge.properties commons-logging.properties crypto.properties xes.keystore ec2-service.properties; do \
mv $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/$$i $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/; \
done
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/log4j-vmops.xml
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/log4j.properties
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/db.properties
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/LICENSE.txt
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/NOTICE.txt
rm $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/services.xml
rm -rf $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi/WEB-INF/classes/META-INF
dh_installdirs
dh_install

View File

@ -26,7 +26,7 @@
<bookinfo id="cloudstack_admin">
<title>&PRODUCT; Administrator's Guide</title>
<productname>Apache CloudStack</productname>
<productnumber>4.0.0-incubating</productnumber>
<productnumber>4.2.0</productnumber>
<edition>1</edition>
<pubsnumber></pubsnumber>
<abstract>

View File

@ -27,7 +27,7 @@
<title>&PRODUCT; Guide</title>
<subtitle>Revised August 9, 2012 10:48 pm Pacific</subtitle>
<productname>Apache CloudStack</productname>
<productnumber>4.0.0</productnumber>
<productnumber>4.2.0</productnumber>
<edition>1</edition>
<pubsnumber></pubsnumber>
<abstract>

View File

@ -28,7 +28,7 @@
<bookinfo id="cloudstack_plugin_niciranvp">
<title>&PRODUCT; Plugin Guide for the Nicira NVP Plugin</title>
<productname>Apache CloudStack</productname>
<productnumber>4.0.0-incubating</productnumber>
<productnumber>4.2.0</productnumber>
<edition>1</edition>
<pubsnumber></pubsnumber>
<abstract>

View File

@ -26,7 +26,7 @@
<bookinfo id="cloudstack_developers">
<title>&PRODUCT; Developer's Guide</title>
<productname>Apache CloudStack</productname>
<productnumber>4.1.0-incubating</productnumber>
<productnumber>4.2.0</productnumber>
<edition></edition>
<pubsnumber></pubsnumber>
<abstract>

View File

@ -25,7 +25,7 @@
<bookinfo id="book-installation">
<title>&PRODUCT; Installation Guide</title>
<productname>Apache CloudStack</productname>
<productnumber>4.0.0</productnumber>
<productnumber>4.2.0</productnumber>
<edition>1</edition>
<pubsnumber/>
<abstract>

File diff suppressed because it is too large Load Diff

View File

@ -34,4 +34,5 @@
<xi:include href="hypervisor-host-install-network-openvswitch.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="hypervisor-host-install-firewall.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="hypervisor-host-install-finish.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="hypervisor-host-install-primary-storage.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

View File

@ -75,8 +75,8 @@
</listitem>
<listitem>
<para>Use the System VM template exclusively designed to support IPv6. Download the System
VM template from <ulink url="http://nfs1.lab.vmops.com/templates/routing/debian/ipv6/"
>http://nfs1.lab.vmops.com/templates/routing/debian/ipv6/</ulink>.</para>
VM template from <ulink url="http://cloudstack.apt-get.eu/systemvm/"
>http://cloudstack.apt-get.eu/systemvm/</ulink>.</para>
</listitem>
<listitem>
<para>The concept of Default Network applies to IPv6 networks. However, unlike IPv4

View File

@ -26,6 +26,7 @@
<xi:include href="creating-vms.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="accessing-vms.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="stopping-and-starting-vms.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="vm-snapshots.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="changing-vm-name-os-group.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="changing-service-offering-for-vm.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="manual-live-migration.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>

146
docs/en-US/vm-snapshots.xml Normal file
View File

@ -0,0 +1,146 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<section id="vm-snapshots">
<title>Virtual Machine Snapshots for VMware</title>
<para>(VMware hosts only)
In addition to the existing &PRODUCT; ability to snapshot VM volumes,
you can now take a VM snapshot to preserve all of the VM's state and data.
This is useful for quick restore of a VM.
For example, you can snapshot a VM, then make changes such as software upgrades.
If anything goes wrong, simply restore the VM to its previous state using the previously saved VM snapshot.
</para>
<para>The snapshot is created using the VMware native snapshot facility. The VM snapshot
includes not only the data volumes, but optionally also whether the VM is running or
turned off (CPU state) and the memory contents. The snapshot is stored in &PRODUCT;'s
primary storage.</para>
<para>VM snapshots can have a parent/child relationship.
Each successive snapshot of the same VM is the child of the snapshot that came before it.
Each time you take an additional snapshot of the same VM, it saves only the differences
between the current state of the VM and the state stored in the most recent previous snapshot.
The previous snapshot becomes a parent, and the new snapshot is its child.
It is possible to create a long chain of these parent/child snapshots,
which amount to a "redo" record leading from the current state of the VM back to the
original.</para>
<para>If you need more information about VM snapshots, check out the VMware documentation
and the VMware Knowledge Base, especially
<ulink url="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&amp;externalId=1015180">Understanding virtual machine snapshots</ulink>.</para>
<section id="vm-snapshot-restrictions">
<title>Limitations on VM Snapshots</title>
<itemizedlist>
<listitem><para>If a VM has some stored snapshots, you can't attach new volume to the VM
or delete any existing volumes.
If you change the volumes on the VM, it would become impossible to restore the VM snapshot
which was created with the previous volume structure.</para></listitem>
<listitem><para>VM snapshots which include both data volumes and memory can't be kept if you change the VM's
service offering. Any existing VM snapshots of this type will be discarded.</para></listitem>
<listitem>
<para>You can't make a VM snapshot at the same time as you are taking a volume
snapshot.</para>
</listitem>
<listitem>
<para>The "quiesce" option is not supported. This option is provided by the underlying
VMware snapshot facility so that you can choose whether to quiesce the file system
on a running virtual machine before taking the snapshot. In &PRODUCT;, the quiesce option is always
set to false; the file system is not quiesced before taking a snapshot of a running VM.
</para>
</listitem>
<listitem><para>You should use only &PRODUCT; to create VM snapshots on VMware hosts managed by &PRODUCT;.
Any snapshots that you make directly on vSphere will not be tracked in &PRODUCT;.</para></listitem>
</itemizedlist>
</section>
<section id="vm-snapshot-configure">
<title>Configuring VM Snapshots</title>
<para>The cloud administrator can use global configuration variables to control the behavior of VM snapshots.
To set these variables, go through the Global Settings are of the UI.</para>
<informaltable>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<thead>
<row>
<entry><para>Configuration Setting Name</para></entry>
<entry><para>Description</para></entry>
</row>
</thead>
<tbody>
<row>
<entry><para>vmsnapshots.max</para></entry>
<entry><para>The maximum number of VM snapshots that can be saved for any given virtual machine in the cloud.
The total possible number of VM snapshots in the cloud is (number of VMs) * vmsnapshots.max.
If the number of snapshots for any VM ever hits the maximum, the older ones are removed
by the snapshot expunge job.
</para></entry>
</row>
<row>
<entry><para>vmsnapshot.create.wait</para></entry>
<entry><para>Number of seconds to wait for a snapshot job to succeed before declaring failure and issuing an error.</para></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section id="vm-snapshot-usage">
<title>Using VM Snapshots</title>
<para>To create a VM snapshot using the &PRODUCT; UI:</para>
<orderedlist>
<listitem><para>Log in to the &PRODUCT; UI as a user or administrator.</para></listitem>
<listitem><para>Click Instances.</para></listitem>
<listitem><para>Click the name of the VM you want to snapshot.</para></listitem>
<listitem><para>Click the Take VM Snapshot button.
<inlinemediaobject>
<imageobject>
<imagedata fileref="./images/VMSnapshotButton.png" format="PNG"/>
</imageobject>
</inlinemediaobject></para>
<note><para>If a snapshot is already in progress, then clicking this button will have no effect.</para></note><para/>
</listitem>
<listitem><para>Provide a name and description. These will be displayed in the VM Snapshots list.</para></listitem>
<listitem><para>(For running VMs only) If you want to include the VM's memory in the snapshot, click the
Memory checkbox. This saves the CPU and memory state of the virtual machine. If you
don't check this box, then only the current state of the VM disk is saved. Checking
this box makes the snapshot take longer.</para></listitem>
<listitem><para>Click OK.</para></listitem>
</orderedlist>
<para>To delete a snapshot or restore a VM to the state saved in a particular snapshot:</para>
<orderedlist>
<listitem><para>Navigate to the VM as described in the earlier steps.</para></listitem>
<listitem><para>Click View VM Snapshots.</para></listitem>
<listitem><para>In the list of snapshots, click the name of the snapshot you want to work with.</para></listitem>
<listitem><para>Depending on what you want to do:</para>
<para>To delete the snapshot, click the Delete button.
<inlinemediaobject>
<imageobject>
<imagedata fileref="./images/delete-button.png" format="PNG"/>
</imageobject>
</inlinemediaobject></para>
<para>To revert to the snapshot, click the Revert button.
<inlinemediaobject>
<imageobject>
<imagedata fileref="./images/revert-vm.png" format="PNG"/>
</imageobject>
</inlinemediaobject></para>
</listitem>
</orderedlist>
<note><para>VM snapshots are deleted automatically when a VM is destroyed.
You don't have to manually delete the snapshots in this case.</para></note>
</section>
</section>

View File

@ -34,7 +34,7 @@ public class CommandResult {
return !this.success;
}
public void setSucess(boolean success) {
public void setSuccess(boolean success) {
this.success = success;
}

View File

@ -26,7 +26,7 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
Creating2("This is only used with createOnlyRequested event"),
Creating("The object is being creating on data store"),
Created("The object is created"),
Ready("Template downloading is complished"),
Ready("Template downloading is accomplished"),
Copying("The object is being coping"),
Destroying("Template is destroying"),
Destroyed("Template is destroyed"),

View File

@ -36,7 +36,9 @@ import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AffinityConflictException;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@ -55,7 +57,7 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineProfile;
@ -69,42 +71,45 @@ public class VMEntityManagerImpl implements VMEntityManager {
protected VMInstanceDao _vmDao;
@Inject
protected VMTemplateDao _templateDao = null;
@Inject
protected ServiceOfferingDao _serviceOfferingDao;
@Inject
protected DiskOfferingDao _diskOfferingDao = null;
@Inject
protected NetworkDao _networkDao;
@Inject
protected AccountDao _accountDao = null;
@Inject
protected UserDao _userDao = null;
@Inject
@Inject
protected VMEntityDao _vmEntityDao;
@Inject
@Inject
protected VMReservationDao _reservationDao;
@Inject
protected VirtualMachineManager _itMgr;
@Inject
protected List<DeploymentPlanner> _planners;
@Inject
protected VolumeDao _volsDao;
@Inject
protected PrimaryDataStoreDao _storagePoolDao;
@Inject
DataStoreManager dataStoreMgr;
@Inject
DeploymentPlanningManager _dpMgr;
@Override
public VMEntityVO loadVirtualMachine(String vmId) {
// TODO Auto-generated method stub
@ -114,11 +119,11 @@ public class VMEntityManagerImpl implements VMEntityManager {
@Override
public void saveVirtualMachine(VMEntityVO entity) {
_vmEntityDao.persist(entity);
}
@Override
public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude)
public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude)
throws InsufficientCapacityException, ResourceUnavailableException {
//call planner and get the deployDestination.
@ -130,12 +135,12 @@ public class VMEntityManagerImpl implements VMEntityManager {
if(planToDeploy != null && planToDeploy.getDataCenterId() != 0){
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId());
}
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
if(!vols.isEmpty()){
VolumeVO vol = vols.get(0);
StoragePool pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
if (!pool.isInMaintenance()) {
long rootVolDcId = pool.getDataCenterId();
Long rootVolPodId = pool.getPodId();
@ -156,21 +161,21 @@ public class VMEntityManagerImpl implements VMEntityManager {
}
}
}
DeployDestination dest;
try {
dest = _dpMgr.planDeployment(vmProfile, plan, exclude);
} catch (AffinityConflictException e) {
throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
}
DeploymentPlanner planner = ComponentContext.getComponent(plannerToUse);
DeployDestination dest = null;
if (planner.canHandle(vmProfile, plan, exclude)) {
dest = planner.plan(vmProfile, plan, exclude);
}
if (dest != null) {
//save destination with VMEntityVO
VMReservationVO vmReservation = new VMReservationVO(vm.getId(), dest.getDataCenter().getId(), dest.getPod().getId(), dest.getCluster().getId(), dest.getHost().getId());
Map<Long,Long> volumeReservationMap = new HashMap<Long,Long>();
if (vm.getHypervisorType() != HypervisorType.BareMetal) {
for(Volume vo : dest.getStorageForDisks().keySet()){
volumeReservationMap.put(vo.getId(), dest.getStorageForDisks().get(vo).getId());
@ -180,21 +185,21 @@ public class VMEntityManagerImpl implements VMEntityManager {
vmEntityVO.setVmReservation(vmReservation);
_vmEntityDao.persist(vmEntityVO);
return vmReservation.getUuid();
}else{
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
}
}
@Override
public void deployVirtualMachine(String reservationId, String caller, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException{
//grab the VM Id and destination using the reservationId.
VMReservationVO vmReservation = _reservationDao.findByReservationId(reservationId);
long vmId = vmReservation.getVmId();
VMInstanceVO vm = _vmDao.findById(vmId);
//Pass it down
Long poolId = null;
@ -205,12 +210,17 @@ public class VMEntityManagerImpl implements VMEntityManager {
poolId = storage.get(volIdList.get(0));
}
}
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(),
DataCenterDeployment reservedPlan = new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(),
vmReservation.getHostId(), null , null);
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), plan);
try{
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), reservedPlan);
}catch(Exception ex){
//Retry the deployment without using the reservation plan
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), null, null,null, null , null);
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), plan);
}
}
@Override
@ -227,7 +237,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
return _itMgr.destroy(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
}
}

View File

@ -51,7 +51,6 @@ import com.cloud.user.dao.AccountDao;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ComponentContext;
import com.cloud.vm.NicProfile;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.dao.UserVmDao;
@ -66,25 +65,25 @@ public class CloudOrchestrator implements OrchestrationService {
@Inject
private VirtualMachineManager _itMgr;
@Inject
protected VMTemplateDao _templateDao = null;
@Inject
protected VMInstanceDao _vmDao;
@Inject
protected UserVmDao _userVmDao = null;
@Inject
protected ServiceOfferingDao _serviceOfferingDao;
@Inject
protected DiskOfferingDao _diskOfferingDao = null;
@Inject
protected NetworkDao _networkDao;
@Inject
protected AccountDao _accountDao = null;
@ -147,17 +146,17 @@ public class CloudOrchestrator implements OrchestrationService {
@Override
public VirtualMachineEntity createVirtualMachine(
String id,
String owner,
String templateId,
String hostName,
String id,
String owner,
String templateId,
String hostName,
String displayName,
String hypervisor,
int cpu,
int speed,
int cpu,
int speed,
long memory,
Long diskSize,
List<String> computeTags,
List<String> computeTags,
List<String> rootDiskTags,
Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
@ -173,22 +172,22 @@ public class CloudOrchestrator implements OrchestrationService {
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
//load vm instance and offerings and call virtualMachineManagerImpl
VMInstanceVO vm = _vmDao.findByUuid(id);
// If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk
// Else, a disk offering is optional, and if present will be used to create the data disk
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>();
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
rootDiskOffering.first(offering);
if(vm.getDiskOfferingId() != null){
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
if (diskOffering == null) {
@ -205,32 +204,32 @@ public class CloudOrchestrator implements OrchestrationService {
}
dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
}
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
return null;
}
return vmEntity;
}
@Override
public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner, String isoId, String hostName, String displayName, String hypervisor, String os, int cpu, int speed, long memory,Long diskSize,
List<String> computeTags, List<String> rootDiskTags, Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
//load vm instance and offerings and call virtualMachineManagerImpl
VMInstanceVO vm = _vmDao.findByUuid(id);
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
rootDiskOffering.first(offering);
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>();
Long diskOfferingId = vm.getDiskOfferingId();
if (diskOfferingId == null) {
@ -251,7 +250,7 @@ public class CloudOrchestrator implements OrchestrationService {
}
rootDiskOffering.first(diskOffering);
rootDiskOffering.second(size);
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
for (String uuid : networkNicMap.keySet()) {
NetworkVO network = _networkDao.findByUuid(uuid);
@ -259,13 +258,13 @@ public class CloudOrchestrator implements OrchestrationService {
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
}
}
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
return null;
}
return vmEntity;
}

View File

@ -33,6 +33,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
import org.apache.log4j.Logger;
@ -45,8 +47,8 @@ import com.cloud.agent.api.to.SwiftTO;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.storage.RegisterVolumePayload;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateZoneVO;
@ -80,6 +82,7 @@ public class AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
@Inject SnapshotDao snapshotDao;
@Inject AgentManager agentMgr;
@Inject SnapshotManager snapshotMgr;
@Inject PrimaryDataStoreDao primaryDataStoreDao;
@Inject
private SwiftManager _swiftMgr;
@Inject
@ -196,9 +199,10 @@ public class AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
}
SwiftTO swift = _swiftMgr.getSwiftTO(snapshot.getSwiftId());
S3TO s3 = _s3Mgr.getS3TO();
VolumeVO volume = volumeDao.findById(volumeId);
StoragePoolVO pool = primaryDataStoreDao.findById(volume.getPoolId());
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
backupOfSnapshot, false);
Answer answer = agentMgr.sendToSSVM(dcId, cmd);

View File

@ -70,12 +70,12 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
CommandResult result = new CommandResult();
if (!answer.getResult()) {
result.setSucess(answer.getResult());
result.setSuccess(answer.getResult());
result.setResult(answer.getDetails());
} else {
TemplateOnPrimaryDataStoreInfo templateStore = context.getTemplate();
templateStore.setPath(answer.getPath());
result.setSucess(true);
result.setSuccess(true);
}
parentCall.complete(result);

View File

@ -23,7 +23,7 @@ import java.util.UUID;
import javax.inject.Inject;
import org.apache.cloudstack.storage.to.ImageDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.TemplateTO;
import org.mockito.Mockito;
@ -126,7 +126,7 @@ public class DirectAgentTest extends CloudStackTestNGBase {
@Test
public void testDownloadTemplate() {
ImageOnPrimayDataStoreTO image = Mockito.mock(ImageOnPrimayDataStoreTO.class);
ImageOnPrimaryDataStoreTO image = Mockito.mock(ImageOnPrimaryDataStoreTO.class);
PrimaryDataStoreTO primaryStore = Mockito.mock(PrimaryDataStoreTO.class);
Mockito.when(primaryStore.getUuid()).thenReturn(this.getLocalStorageUuid());
Mockito.when(image.getPrimaryDataStore()).thenReturn(primaryStore);

View File

@ -29,9 +29,9 @@ import org.apache.cloudstack.storage.HypervisorHostEndPoint;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public class MockHypervsiorHostEndPointRpcServer implements HostEndpointRpcServer {
public class MockHypervisorHostEndPointRpcServer implements HostEndpointRpcServer {
private ScheduledExecutorService executor;
public MockHypervsiorHostEndPointRpcServer() {
public MockHypervisorHostEndPointRpcServer() {
executor = Executors.newScheduledThreadPool(10);
}

View File

@ -75,7 +75,7 @@
</bean>
<bean id="ExteralIpAddressAllocator" class="com.cloud.network.ExteralIpAddressAllocator">
<bean id="ExternalIpAddressAllocator" class="com.cloud.network.ExternalIpAddressAllocator">
<property name="name" value="Basic"/>
</bean>

View File

@ -106,7 +106,7 @@ public class SnapshotObject implements SnapshotInfo {
@Override
public Long getSize() {
return this.getSize();
return this.snapshot.getSize();
}
@Override

View File

@ -36,16 +36,16 @@ import com.cloud.agent.api.Command;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
public class HypervsiorHostEndPointRpcServer implements HostEndpointRpcServer {
private static final Logger s_logger = Logger.getLogger(HypervsiorHostEndPointRpcServer.class);
public class HypervisorHostEndPointRpcServer implements HostEndpointRpcServer {
private static final Logger s_logger = Logger.getLogger(HypervisorHostEndPointRpcServer.class);
@Inject
private RpcProvider rpcProvider;
public HypervsiorHostEndPointRpcServer() {
public HypervisorHostEndPointRpcServer() {
}
public HypervsiorHostEndPointRpcServer(RpcProvider rpcProvider) {
public HypervisorHostEndPointRpcServer(RpcProvider rpcProvider) {
rpcProvider = rpcProvider;
rpcProvider.registerRpcServiceEndpoint(RpcServiceDispatcher.getDispatcher(this));
}
@ -91,7 +91,7 @@ public class HypervsiorHostEndPointRpcServer implements HostEndpointRpcServer {
@Override
public Answer sendCommand(HypervisorHostEndPoint host, Command command) {
SendCommandContext<Answer> context = new SendCommandContext<Answer>(null);
AsyncCallbackDispatcher<HypervsiorHostEndPointRpcServer, Answer> caller = AsyncCallbackDispatcher.create(this);
AsyncCallbackDispatcher<HypervisorHostEndPointRpcServer, Answer> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().sendCommandCallback(null, null))
.setContext(context);
@ -109,7 +109,7 @@ public class HypervsiorHostEndPointRpcServer implements HostEndpointRpcServer {
return context.getAnswer();
}
protected Object sendCommandCallback(AsyncCallbackDispatcher<HypervsiorHostEndPointRpcServer, Answer> callback, SendCommandContext<Answer> context) {
protected Object sendCommandCallback(AsyncCallbackDispatcher<HypervisorHostEndPointRpcServer, Answer> callback, SendCommandContext<Answer> context) {
context.setAnswer((Answer)callback.getResult());
synchronized(context) {
context.notify();

View File

@ -176,7 +176,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
Long clusterId = pool.getClusterId();
ClusterVO cluster = _clusterDao.findById(clusterId);
if (!(cluster.getHypervisorType() == dskCh.getHypersorType())) {
if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool");
}

View File

@ -57,7 +57,7 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator {
DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool");
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
HypervisorType hypervisor = dskCh.getHypersorType();
HypervisorType hypervisor = dskCh.getHypervisorType();
if (hypervisor != null) {
if (hypervisor != HypervisorType.KVM) {
s_logger.debug("Only kvm supports zone wide storage");

View File

@ -18,14 +18,14 @@
*/
package org.apache.cloudstack.storage.command;
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.VolumeTO;
import com.cloud.agent.api.Command;
public class CreateVolumeFromBaseImageCommand extends Command implements StorageSubSystemCommand {
private final VolumeTO volume;
private final ImageOnPrimayDataStoreTO image;
private final ImageOnPrimaryDataStoreTO image;
public CreateVolumeFromBaseImageCommand(VolumeTO volume, String image) {
this.volume = volume;
@ -36,7 +36,7 @@ public class CreateVolumeFromBaseImageCommand extends Command implements Storage
return this.volume;
}
public ImageOnPrimayDataStoreTO getImage() {
public ImageOnPrimaryDataStoreTO getImage() {
return this.image;
}

View File

@ -109,7 +109,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
if (obj == null) {
CreateCmdResult result = new CreateCmdResult(
null, null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return;
@ -124,7 +124,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
data, store);
} catch (Exception e) {
CreateCmdResult result = new CreateCmdResult(null, null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return;
@ -153,7 +153,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
s_logger.debug("state transation failed", e1);
}
CreateCmdResult result = new CreateCmdResult(null, null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return;

View File

@ -64,7 +64,7 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
return null;
}
public List<StorageProviderResponse> getPrimayrDataStoreProviders() {
public List<StorageProviderResponse> getPrimaryDataStoreProviders() {
List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>();
for (DataStoreProvider provider : providerMap.values()) {
if (provider instanceof PrimaryDataStoreProvider) {
@ -138,7 +138,7 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
throw new InvalidParameterValueException("Invalid parameter, need to specify type: either primary or image");
}
if (type.equalsIgnoreCase(DataStoreProvider.DataStoreProviderType.PRIMARY.toString())) {
return this.getPrimayrDataStoreProviders();
return this.getPrimaryDataStoreProviders();
} else if (type.equalsIgnoreCase(DataStoreProvider.DataStoreProviderType.IMAGE.toString())) {
return this.getImageDataStoreProviders();
} else {

View File

@ -20,11 +20,11 @@ package org.apache.cloudstack.storage.to;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
public class ImageOnPrimayDataStoreTO {
public class ImageOnPrimaryDataStoreTO {
private final String pathOnPrimaryDataStore;
private PrimaryDataStoreTO dataStore;
private final TemplateTO template;
public ImageOnPrimayDataStoreTO(TemplateOnPrimaryDataStoreInfo template) {
public ImageOnPrimaryDataStoreTO(TemplateOnPrimaryDataStoreInfo template) {
this.pathOnPrimaryDataStore = template.getPath();
//this.dataStore = template.getPrimaryDataStore().getDataStoreTO();
this.template = new TemplateTO(template.getTemplate());

View File

@ -144,12 +144,12 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
CommandResult result = new CommandResult();
if (answer == null || answer.getDetails() != null) {
result.setSucess(false);
result.setSuccess(false);
if (answer != null) {
result.setResult(answer.getDetails());
}
} else {
result.setSucess(true);
result.setSuccess(true);
VolumeObject volume = context.getVolume();
volume.setPath(answer.getVolumeUuid());
}

View File

@ -42,7 +42,7 @@ public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProv
@Inject
PrimaryDataStoreProviderManager storeMgr;
protected DataStoreLifeCycle lifecyle;
protected DataStoreLifeCycle lifecycle;
protected String uuid;
protected long id;
@Override
@ -52,12 +52,12 @@ public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProv
@Override
public DataStoreLifeCycle getDataStoreLifeCycle() {
return this.lifecyle;
return this.lifecycle;
}
@Override
public boolean configure(Map<String, Object> params) {
lifecyle = ComponentContext.inject(DefaultPrimaryDataStoreLifeCycleImpl.class);
lifecycle = ComponentContext.inject(DefaultPrimaryDataStoreLifeCycleImpl.class);
driver = ComponentContext.inject(DefaultPrimaryDataStoreDriverImpl.class);
listener = ComponentContext.inject(DefaultHostListener.class);
return true;

View File

@ -107,7 +107,7 @@ public class TemplateInstallStrategyImpl implements TemplateInstallStrategy {
if (obj == null) {
CreateBaseImageResult result = new CreateBaseImageResult(
null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return null;
@ -122,7 +122,7 @@ public class TemplateInstallStrategyImpl implements TemplateInstallStrategy {
template, store);
} catch (Exception e) {
CreateBaseImageResult result = new CreateBaseImageResult(null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return null;
@ -145,7 +145,7 @@ public class TemplateInstallStrategyImpl implements TemplateInstallStrategy {
s_logger.debug("state transation failed", e1);
}
CreateBaseImageResult result = new CreateBaseImageResult(null);
result.setSucess(false);
result.setSuccess(false);
result.setResult(e.toString());
callback.complete(result);
return null;

View File

@ -58,7 +58,7 @@ export JAVA_HOME
SCP=""
DCP=""
UCP=`ls /usr/share/cloudstack-usage/cloud-usage-*.jar`":"`ls /usr/share/cloudstack-usage/lib/* | tr '\n' ':'`
UCP=`ls /usr/share/cloudstack-usage/cloud-usage-*.jar`":"`ls /usr/share/cloudstack-usage/lib/*.jar | tr '\n' ':'`
JCP="/usr/share/java/commons-daemon.jar"
# We need to append the JSVC daemon JAR to the classpath

View File

@ -278,6 +278,8 @@ cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib
install -D usage/target/cloud-usage-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/cloud-usage-%{_maventag}.jar
install -D usage/target/transformed/db.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage/db.properties
install -D usage/target/transformed/log4j-cloud_usage.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage/log4j-cloud.xml
cp usage/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib/
install -D packaging/centos63/cloud-usage.rc ${RPM_BUILD_ROOT}/%{_sysconfdir}/init.d/%{name}-usage
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/usage/
@ -438,6 +440,13 @@ if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then
mv %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/cloud.rpmsave/agent/agent.properties.rpmsave
fi
%post usage
if [ -f "%{_sysconfdir}/%{name}/management/db.properties" ]; then
echo Replacing db.properties with management server db.properties
rm -f %{_sysconfdir}/%{name}/usage/db.properties
ln -s %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/usage/db.properties
fi
#%post awsapi
#if [ -d "%{_datadir}/%{name}-management" ] ; then
# ln -s %{_datadir}/%{name}-bridge/webapps %{_datadir}/%{name}-management/webapps7080
@ -532,8 +541,9 @@ fi
%attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-usage
%attr(0644,root,root) %{_datadir}/%{name}-usage/*.jar
%attr(0644,root,root) %{_datadir}/%{name}-usage/lib/*.jar
%dir /var/log/%{name}/usage
%dir %{_sysconfdir}/%{name}/usage
%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/usage
%attr(0644,root,root) %{_sysconfdir}/%{name}/usage/db.properties
%attr(0644,root,root) %{_sysconfdir}/%{name}/usage/log4j-cloud.xml
%{_defaultdocdir}/%{name}-usage-%{version}/LICENSE
%{_defaultdocdir}/%{name}-usage-%{version}/NOTICE

View File

@ -56,5 +56,5 @@ SYSCONFDIR=/etc/sysconfig
SYSTEMCLASSPATH=
SYSTEMJARS=
USAGECLASSPATH=
USAGELOG=/var/log/cloudstack/usage
USAGELOG=/var/log/cloudstack/usage/usage.log
USAGESYSCONFDIR=/etc/sysconfig

View File

@ -0,0 +1,33 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-host-anti-affinity</artifactId>
<name>Apache CloudStack Plugin - Host Anti-Affinity Processor</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
</build>
</project>

View File

@ -0,0 +1,93 @@
// 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.affinity;
import java.util.List;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.log4j.Logger;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AffinityConflictException;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@Local(value = AffinityGroupProcessor.class)
public class HostAntiAffinityProcessor extends AffinityProcessorBase implements AffinityGroupProcessor {
private static final Logger s_logger = Logger.getLogger(HostAntiAffinityProcessor.class);
@Inject
protected UserVmDao _vmDao;
@Inject
protected VMInstanceDao _vmInstanceDao;
@Inject
protected AffinityGroupDao _affinityGroupDao;
@Inject
protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
@Override
public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan,
ExcludeList avoid)
throws AffinityConflictException {
VirtualMachine vm = vmProfile.getVirtualMachine();
List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
if (vmGroupMapping != null) {
AffinityGroupVO group = _affinityGroupDao.findById(vmGroupMapping.getAffinityGroupId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Processing affinity group " + group.getName() + " for VM Id: " + vm.getId());
}
List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
groupVMIds.remove(vm.getId());
for (Long groupVMId : groupVMIds) {
VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
if (groupVM != null && !groupVM.isRemoved()) {
if (groupVM.getHostId() != null) {
avoid.addHost(groupVM.getHostId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Added host " + groupVM.getHostId() + " to avoid set, since VM "
+ groupVM.getId() + " is present on the host");
}
} else if (VirtualMachine.State.Stopped.equals(groupVM.getState())
&& groupVM.getLastHostId() != null) {
avoid.addHost(groupVM.getLastHostId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM "
+ groupVM.getId() + " is present on the host, in Stopped state");
}
}
}
}
}
}
}
}

View File

@ -217,7 +217,7 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
message.append("unknown" + MESSAGE_DELIMITER_STRING);
}
if (alertType > 0) {
if (alertType >= 0) {
message.append("alertType").append(_keyValueDelimiter).append(" ").append(alertsMap.get(alertType))
.append(MESSAGE_DELIMITER_STRING);
if (dataCenterId != 0) {
@ -333,4 +333,4 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
public void setKeyValueDelimiter(String keyValueDelimiter) {
this._keyValueDelimiter = keyValueDelimiter;
}
}
}

View File

@ -27,6 +27,7 @@ import java.util.Map;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -40,6 +41,8 @@ import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.cluster.ClusterManager;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
@ -49,7 +52,9 @@ import com.cloud.hypervisor.HypervisorGuru;
import com.cloud.hypervisor.HypervisorGuruBase;
import com.cloud.hypervisor.vmware.manager.VmwareManager;
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
import com.cloud.network.Network.Provider;
import com.cloud.network.NetworkModel;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkVO;
@ -84,6 +89,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
@Inject VmwareManager _vmwareMgr;
@Inject SecondaryStorageVmManager _secStorageMgr;
@Inject NetworkModel _networkMgr;
@Inject ConfigurationDao _configDao;
protected VMwareGuru() {
super();
@ -139,13 +145,23 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
details.put(VmDetailConstants.ROOK_DISK_CONTROLLER, _vmwareMgr.getRootDiskController());
}
}
List<NicProfile> nicProfiles = vm.getNics();
for(NicProfile nicProfile : nicProfiles) {
if(nicProfile.getTrafficType() == TrafficType.Guest) {
if(_networkMgr.isProviderSupportServiceInNetwork(nicProfile.getNetworkId(), Service.Firewall, Provider.CiscoVnmc)) {
details.put("ConfigureVServiceInNexus", Boolean.TRUE.toString());
}
break;
}
}
to.setDetails(details);
if(vm.getVirtualMachine() instanceof DomainRouterVO) {
List<NicProfile> nicProfiles = vm.getNics();
NicProfile publicNicProfile = null;
NicProfile publicNicProfile = null;
for(NicProfile nicProfile : nicProfiles) {
if(nicProfile.getTrafficType() == TrafficType.Public) {
publicNicProfile = nicProfile;
@ -212,8 +228,21 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
sbMacSequence.deleteCharAt(sbMacSequence.length() - 1);
String bootArgs = to.getBootArgs();
to.setBootArgs(bootArgs + " nic_macs=" + sbMacSequence.toString());
}
// Don't do this if the virtual machine is one of the special types
// Should only be done on user machines
if(!(vm.getVirtualMachine() instanceof DomainRouterVO || vm.getVirtualMachine() instanceof ConsoleProxyVO
|| vm.getVirtualMachine() instanceof SecondaryStorageVmVO)) {
String nestedVirt = _configDao.getValue(Config.VmwareEnableNestedVirtualization.key());
if (nestedVirt != null) {
s_logger.debug("Nested virtualization requested, adding flag to vm configuration");
details.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, nestedVirt);
to.setDetails(details);
}
}
// Determine the VM's OS description
GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
to.setOs(guestOS.getDisplayName());

View File

@ -317,8 +317,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
}
s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
}
@Override

View File

@ -232,6 +232,7 @@ import com.vmware.vim25.ClusterDasConfigInfo;
import com.vmware.vim25.ComputeResourceSummary;
import com.vmware.vim25.DatastoreSummary;
import com.vmware.vim25.DynamicProperty;
import com.vmware.vim25.HostCapability;
import com.vmware.vim25.HostFirewallInfo;
import com.vmware.vim25.HostFirewallRuleset;
import com.vmware.vim25.HostNetworkTrafficShapingPolicy;
@ -1328,7 +1329,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
NicTO nicTo = cmd.getNic();
VirtualDevice nic;
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, false);
if (VmwareHelper.isDvPortGroup(networkInfo.first())) {
String dvSwitchUuid;
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
@ -1570,7 +1571,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
} else {
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, vSwitchType, _portsPerDvPortGroup);
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false);
}
int nicIndex = allocPublicNicIndex(vmMo);
@ -2147,6 +2148,23 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(),
vmSpec.getMinSpeed(),(int) (vmSpec.getMaxRam()/(1024*1024)), ramMb,
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), vmSpec.getLimitCpuUse());
if ("true".equals(vmSpec.getDetails().get(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG))) {
s_logger.debug("Nested Virtualization enabled in configuration, checking hypervisor capability");
ManagedObjectReference hostMor = vmMo.getRunningHost().getMor();
ManagedObjectReference computeMor = context.getVimClient().getMoRefProp(hostMor, "parent");
ManagedObjectReference environmentBrowser =
context.getVimClient().getMoRefProp(computeMor, "environmentBrowser");
HostCapability hostCapability = context.getService().queryTargetCapabilities(environmentBrowser, hostMor);
if (hostCapability.isNestedHVSupported()) {
s_logger.debug("Hypervisor supports nested virtualization, enabling for VM " + vmSpec.getName());
vmConfigSpec.setNestedHVEnabled(true);
}
else {
s_logger.warn("Hypervisor doesn't support nested virtualization, unable to set config for VM " +vmSpec.getName());
vmConfigSpec.setNestedHVEnabled(false);
}
}
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
int i = 0;
@ -2286,7 +2304,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
for (NicTO nicTo : sortNicsByDeviceId(nics)) {
s_logger.info("Prepare NIC device based on NicTO: " + _gson.toJson(nicTo));
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
boolean configureVServiceInNexus = (nicTo.getType() == TrafficType.Guest) && (vmSpec.getDetails().containsKey("ConfigureVServiceInNexus"));
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, configureVServiceInNexus);
if (VmwareHelper.isDvPortGroup(networkInfo.first())) {
String dvSwitchUuid;
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
@ -2486,7 +2505,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return defaultVlan;
}
private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo) throws Exception {
private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo, boolean configureVServiceInNexus) throws Exception {
Pair<String, String> switchName;
TrafficType trafficType;
VirtualSwitchType switchType;
@ -2516,7 +2535,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
else {
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup);
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus);
}
return networkInfo;
@ -3006,7 +3025,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
NicTO[] nics = vm.getNics();
for (NicTO nic : nics) {
// prepare network on the host
prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic);
prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic, false);
}
String secStoreUrl = mgr.getSecondaryStorageStoreUrl(Long.parseLong(_dcId));

View File

@ -39,7 +39,7 @@ import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.VolumeTO;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@ -207,7 +207,7 @@ public class XenServerStorageResource {
protected Answer execute(CreateVolumeFromBaseImageCommand cmd) {
VolumeTO volume = cmd.getVolume();
ImageOnPrimayDataStoreTO baseImage = cmd.getImage();
ImageOnPrimaryDataStoreTO baseImage = cmd.getImage();
Connection conn = hypervisorResource.getConnection();
try {

View File

@ -0,0 +1,42 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-network-cisco-vnmc</artifactId>
<name>Apache CloudStack Plugin - Cisco VNMC</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-vmware</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-vmware-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,34 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMo
dn=""
cookie="%cookie%"
inHierarchical="false">
<inConfig>
<fwResourceBinding
assignedToDn="%fwdn%"
dn="%binddn%"
status="created"/>
</inConfig>
</configConfMo>
<!--
assignedToDn="fw/inst-1007"
dn="org-root/org-TenantD/org-VDC-TenantD/efw-ASA-1000v-TenantD/binding"
-->

View File

@ -0,0 +1,37 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMos
cookie="%cookie%"
inHierarchical="false">
<inConfigs>
<pair key="%espdn%">
<policyVirtualNetworkEdgeProfile
connTimeoutRef=""
descr="%descr%"
dn="%espdn%"
egressAclPsetRef="%egresspolicysetname%"
ingressAclPsetRef="%ingresspolicysetname%"
inspectRef=""
name="%name%"
natPsetRef="%natpolicysetname%"
status="modified"
vpnRef=""/>
</pair>
</inConfigs>
</configConfMos>

View File

@ -0,0 +1,34 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMos
cookie="%cookie%"
inHierarchical="false">
<inConfigs>
<pair key="%dhcpdn%">
<policyDhcpPolicyAssoc
dn="%dhcpdn%"
interfaceName="%insideintf%"
policyRef=""
status="created"
type="server"/>
</pair>
</inConfigs>
</configConfMos>
<!--dn="org-root/org-TestTenant3/org-Tenant3-VDC/edsp-Tenant3-Edge-Device-Profile/dhcp-Edge_Inside"-->

View File

@ -0,0 +1,32 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMos
cookie="%cookie%"
inHierarchical="false">
<inConfigs>
<pair key="%dhcpdn%">
<policyDhcpPolicyAssoc
dn="%dhcpdn%"
interfaceName="%insideintf%"
policyRef="%dhcpserverpolicyname%"
status="modified"
type="server"/>
</pair>
</inConfigs>
</configConfMos>

View File

@ -0,0 +1,35 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMos
cookie="%cookie%"
inHierarchical="false">
<inConfigs>
<pair key="%espdn%">
<policyVirtualNetworkEdgeProfile
connTimeoutRef=""
descr="%descr%"
dn="%espdn%"
inspectRef=""
name="%name%"
natPsetRef="%natpolicysetname%"
status="modified"
vpnRef=""/>
</pair>
</inConfigs>
</configConfMos>

View File

@ -0,0 +1,33 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMo
dn=""
cookie="%cookie%"
inHierarchical="false">
<inConfig>
<policyEdgeDeviceServiceProfile
addrTranslationTimeout="10800"
dn="%dn%"
ipAudit=""
name="%name%"
routing="%routepolicyname%"
status="modified"
vpn=""/>
</inConfig>
</configConfMo>

View File

@ -0,0 +1,38 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configConfMos
cookie="%cookie%"
inHierarchical="false">
<inConfigs>
<pair key="%aclpolicyrefdn%">
<policyPolicyNameRef
dn="%aclpolicyrefdn%"
order="%order%"
policyName="%aclpolicyname%"
status="created"/>
</pair>
</inConfigs>
</configConfMos>
<!--
aclpolicyrefdn="org-root/org-vlan-123/org-VDC-vlan-123/pset-Ingress-ACL-Policy-Set-vlan-123/polref-aaa"
aclpolicyname="aaa"
--!>

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