mirror of https://github.com/apache/cloudstack.git
Merge remote-tracking branch 'apple/apple-base418' into scalability-improvements
This commit is contained in:
commit
5e98405b38
|
|
@ -81,7 +81,8 @@ jobs:
|
|||
smoke/test_metrics_api
|
||||
smoke/test_migration
|
||||
smoke/test_multipleips_per_nic
|
||||
smoke/test_nested_virtualization",
|
||||
smoke/test_nested_virtualization
|
||||
smoke/test_purge_expunged_vms",
|
||||
"smoke/test_network
|
||||
smoke/test_network_acl
|
||||
smoke/test_network_ipv6
|
||||
|
|
@ -125,6 +126,7 @@ jobs:
|
|||
smoke/test_usage
|
||||
smoke/test_usage_events
|
||||
smoke/test_vm_deployment_planner
|
||||
smoke/test_vm_strict_host_tags
|
||||
smoke/test_vm_life_cycle
|
||||
smoke/test_vm_lifecycle_unmanage_import
|
||||
smoke/test_vm_snapshot_kvm
|
||||
|
|
|
|||
|
|
@ -415,3 +415,6 @@ iscsi.session.cleanup.enabled=false
|
|||
# If set to "true", the agent will register for libvirt domain events, allowing for immediate updates on crashed or
|
||||
# unexpectedly stopped. Experimental, requires agent restart.
|
||||
# libvirt.events.enabled=false
|
||||
|
||||
# Implicit host tags managed by agent.properties
|
||||
# host.tags=
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
/var/log/cloudstack/agent/security_group.log /var/log/cloudstack/agent/resizevolume.log /var/log/cloudstack/agent/rolling-maintenance.log {
|
||||
/var/log/cloudstack/agent/security_group.log /var/log/cloudstack/agent/resizevolume.log /var/log/cloudstack/agent/rolling-maintenance.log /var/log/cloudstack/agent/agent.out /var/log/cloudstack/agent/agent.err {
|
||||
copytruncate
|
||||
daily
|
||||
rotate 5
|
||||
compress
|
||||
missingok
|
||||
size 10M
|
||||
dateext
|
||||
dateformat -%Y-%m-%d
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,17 +37,17 @@ under the License.
|
|||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- ============================== -->
|
||||
<!-- Append messages to the console -->
|
||||
<!-- ============================== -->
|
||||
|
||||
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
<param name="Threshold" value="INFO"/>
|
||||
<param name="Threshold" value="OFF"/>
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
|
||||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ under the License.
|
|||
<category name="com.cloud">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
|
||||
<category name="com.cloud.agent.metrics">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
|
||||
<category name="com.cloud.agent.resource.computing.ComputingResource$StorageMonitorTask">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
|
@ -75,7 +75,7 @@ under the License.
|
|||
<category name="org">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
|
||||
<category name="net">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
|
|
|||
|
|
@ -755,6 +755,13 @@ public class AgentProperties{
|
|||
*/
|
||||
public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16");
|
||||
|
||||
/**
|
||||
* Implicit host tags
|
||||
* Data type: String.<br>
|
||||
* Default value: <code>null</code>
|
||||
*/
|
||||
public static final Property<String> HOST_TAGS = new Property<>("host.tags", null, String.class);
|
||||
|
||||
public static class Property <T>{
|
||||
private String name;
|
||||
private T defaultValue;
|
||||
|
|
|
|||
|
|
@ -693,6 +693,8 @@ public class EventTypes {
|
|||
|
||||
// SystemVM
|
||||
public static final String EVENT_LIVE_PATCH_SYSTEMVM = "LIVE.PATCH.SYSTEM.VM";
|
||||
//Purge resources
|
||||
public static final String EVENT_PURGE_EXPUNGED_RESOURCES = "PURGE.EXPUNGED.RESOURCES";
|
||||
|
||||
static {
|
||||
|
||||
|
|
|
|||
|
|
@ -317,6 +317,8 @@ public interface NetworkModel {
|
|||
|
||||
void checkIp6Parameters(String startIPv6, String endIPv6, String ip6Gateway, String ip6Cidr) throws InvalidParameterValueException;
|
||||
|
||||
void checkIp6CidrSizeEqualTo64(String ip6Cidr) throws InvalidParameterValueException;
|
||||
|
||||
void checkRequestedIpAddresses(long networkId, IpAddresses ips) throws InvalidParameterValueException;
|
||||
|
||||
String getStartIpv6Address(long id);
|
||||
|
|
|
|||
|
|
@ -48,4 +48,7 @@ public interface LoadBalancingServiceProvider extends NetworkElement, IpDeployin
|
|||
List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule> lbrules);
|
||||
|
||||
boolean handlesOnlyRulesInTransitionState();
|
||||
|
||||
default void expungeLbVmRefs(List<Long> vmIds, Long batchSize) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,4 +208,7 @@ public interface NetworkGuru extends Adapter {
|
|||
|
||||
boolean isMyTrafficType(TrafficType type);
|
||||
|
||||
default boolean isSlaacV6Only() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
|
|||
static final String internalLbVmDefaultOffUniqueName = "Cloud.Com-InternalLBVm";
|
||||
// leaving cloud.com references as these are identifyers and no real world addresses (check against DB)
|
||||
|
||||
|
||||
static final String PURGE_DB_ENTITIES_KEY = "purge.db.entities";
|
||||
|
||||
enum State {
|
||||
Inactive, Active,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ public interface ResourceLimitService {
|
|||
static final ConfigKey<Long> MaxProjectSecondaryStorage = new ConfigKey<>("Project Defaults", Long.class, "max.project.secondary.storage", "400",
|
||||
"The default maximum secondary storage space (in GiB) that can be used for a project", false);
|
||||
static final ConfigKey<Long> ResourceCountCheckInterval = new ConfigKey<>("Advanced", Long.class, "resourcecount.check.interval", "300",
|
||||
"Time (in seconds) to wait before running resource recalculation and fixing task. Default is 300 seconds, Setting this to 0 disables execution of the task", true);
|
||||
"Time (in seconds) to wait before running resource recalculation and fixing tasks like stale resource reservation cleanup" +
|
||||
". Default is 300 seconds, Setting this to 0 disables execution of the task", true);
|
||||
static final ConfigKey<Long> ResourceReservationCleanupDelay = new ConfigKey<>("Advanced", Long.class, "resource.reservation.cleanup.delay", "3600",
|
||||
"Time (in seconds) after which a resource reservation gets deleted. Default is 3600 seconds, Setting this to 0 disables execution of the task", true);
|
||||
static final ConfigKey<String> ResourceLimitHostTags = new ConfigKey<>("Advanced", String.class, "resource.limit.host.tags", "",
|
||||
"A comma-separated list of tags for host resource limits", true);
|
||||
static final ConfigKey<String> ResourceLimitStorageTags = new ConfigKey<>("Advanced", String.class, "resource.limit.storage.tags", "",
|
||||
|
|
|
|||
|
|
@ -190,6 +190,10 @@ public interface VirtualMachineProfile {
|
|||
|
||||
Map<Param, Object> getParameters();
|
||||
|
||||
void setCpuOvercommitRatio(Float cpuOvercommitRatio);
|
||||
|
||||
void setMemoryOvercommitRatio(Float memoryOvercommitRatio);
|
||||
|
||||
Float getCpuOvercommitRatio();
|
||||
|
||||
Float getMemoryOvercommitRatio();
|
||||
|
|
|
|||
|
|
@ -32,4 +32,9 @@ public enum ApiArgValidator {
|
|||
* Validates if the parameter is an UUID with the method {@link UuidUtils#isUuid(String)}.
|
||||
*/
|
||||
UuidString,
|
||||
|
||||
/**
|
||||
* Validates if the parameter is a valid RFC Compliance domain name.
|
||||
*/
|
||||
RFCComplianceDomainName,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ public class ApiConstants {
|
|||
public static final String IS_EDGE = "isedge";
|
||||
public static final String IS_EXTRACTABLE = "isextractable";
|
||||
public static final String IS_FEATURED = "isfeatured";
|
||||
public static final String IS_IMPLICIT = "isimplicit";
|
||||
public static final String IS_PORTABLE = "isportable";
|
||||
public static final String IS_PUBLIC = "ispublic";
|
||||
public static final String IS_PERSISTENT = "ispersistent";
|
||||
|
|
@ -358,6 +359,7 @@ public class ApiConstants {
|
|||
public static final String PUBLIC_START_PORT = "publicport";
|
||||
public static final String PUBLIC_END_PORT = "publicendport";
|
||||
public static final String PUBLIC_ZONE = "publiczone";
|
||||
public static final String PURGE_RESOURCES = "purgeresources";
|
||||
public static final String RECEIVED_BYTES = "receivedbytes";
|
||||
public static final String RECONNECT = "reconnect";
|
||||
public static final String RECOVER = "recover";
|
||||
|
|
@ -417,6 +419,7 @@ public class ApiConstants {
|
|||
public static final String STORAGE_POLICY = "storagepolicy";
|
||||
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
|
||||
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
|
||||
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
|
||||
public static final String SUBNET = "subnet";
|
||||
public static final String OWNER = "owner";
|
||||
public static final String SWAP_OWNER = "swapowner";
|
||||
|
|
@ -848,6 +851,7 @@ public class ApiConstants {
|
|||
public static final String AUTOSCALE_VMGROUP_NAME = "autoscalevmgroupname";
|
||||
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
|
||||
public static final String BAREMETAL_RCT_URL = "baremetalrcturl";
|
||||
public static final String BATCH_SIZE = "batchsize";
|
||||
public static final String UCS_DN = "ucsdn";
|
||||
public static final String GSLB_PROVIDER = "gslbprovider";
|
||||
public static final String EXCLUSIVE_GSLB_PROVIDER = "isexclusivegslbprovider";
|
||||
|
|
|
|||
|
|
@ -244,6 +244,12 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.ENCRYPT_ROOT, type = CommandType.BOOLEAN, description = "VMs using this offering require root volume encryption", since="4.18")
|
||||
private Boolean encryptRoot;
|
||||
|
||||
@Parameter(name = ApiConstants.PURGE_RESOURCES, type = CommandType.BOOLEAN,
|
||||
description = "Whether to cleanup instance and its associated resource from database upon expunge of the instance",
|
||||
since="4.18.1")
|
||||
private Boolean purgeResources;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -259,7 +265,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
|
||||
public String getDisplayText() {
|
||||
if (StringUtils.isEmpty(displayText)) {
|
||||
throw new InvalidParameterValueException("Failed to create service offering because the offering display text has not been spified.");
|
||||
throw new InvalidParameterValueException("Failed to create service offering because the offering display text has not been specified.");
|
||||
}
|
||||
return displayText;
|
||||
}
|
||||
|
|
@ -274,7 +280,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
|
||||
public String getServiceOfferingName() {
|
||||
if (StringUtils.isEmpty(serviceOfferingName)) {
|
||||
throw new InvalidParameterValueException("Failed to create service offering because offering name has not been spified.");
|
||||
throw new InvalidParameterValueException("Failed to create service offering because offering name has not been specified.");
|
||||
}
|
||||
return serviceOfferingName;
|
||||
}
|
||||
|
|
@ -482,6 +488,10 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isPurgeResources() {
|
||||
return Boolean.TRUE.equals(purgeResources);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
|
|||
since = "4.16")
|
||||
private String hostTags;
|
||||
|
||||
@Parameter(name = ApiConstants.PURGE_RESOURCES, type = CommandType.BOOLEAN,
|
||||
description = "Whether to cleanup VM and its associated resource upon expunge",
|
||||
since="4.18.1")
|
||||
private Boolean purgeResources;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -172,6 +177,10 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
|
|||
return hostTags;
|
||||
}
|
||||
|
||||
public boolean isPurgeResources() {
|
||||
return Boolean.TRUE.equals(purgeResources);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,131 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.resource;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
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.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.PurgeExpungedResourcesResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.resource.ResourceCleanupService;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
|
||||
@APICommand(name = "purgeExpungedResources",
|
||||
description = "Purge expunged resources",
|
||||
responseObject = SuccessResponse.class,
|
||||
responseView = ResponseObject.ResponseView.Full,
|
||||
requestHasSensitiveInfo = false,
|
||||
responseHasSensitiveInfo = false,
|
||||
authorized = {RoleType.Admin},
|
||||
since = "4.18.1")
|
||||
public class PurgeExpungedResourcesCmd extends BaseAsyncCmd {
|
||||
|
||||
@Inject
|
||||
ResourceCleanupService resourceCleanupService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.RESOURCE_TYPE, type = BaseCmd.CommandType.STRING,
|
||||
description = "The type of the resource which need to be purged. Supported types: " +
|
||||
"VirtualMachine")
|
||||
private String resourceType;
|
||||
|
||||
@Parameter(name = ApiConstants.BATCH_SIZE, type = CommandType.LONG,
|
||||
description = "The size of batch used during purging")
|
||||
private Long batchSize;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE,
|
||||
type = CommandType.DATE,
|
||||
description = "The start date range of the expunged resources used for purging " +
|
||||
"(use format \"yyyy-MM-dd\" or \"yyyy-MM-dd HH:mm:ss\")")
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE,
|
||||
type = CommandType.DATE,
|
||||
description = "The end date range of the expunged resources used for purging " +
|
||||
"(use format \"yyyy-MM-dd\" or \"yyyy-MM-dd HH:mm:ss\")")
|
||||
private Date endDate;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public Long getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_PURGE_EXPUNGED_RESOURCES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Purging expunged resources";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
long result = resourceCleanupService.purgeExpungedResources(this);
|
||||
PurgeExpungedResourcesResponse response = new PurgeExpungedResourcesResponse();
|
||||
response.setResourceCount(result);
|
||||
response.setObjectName(getCommandName().toLowerCase());
|
||||
setResponseObject(response);
|
||||
} catch (Exception e) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +69,8 @@ public class ListStoragePoolsCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.STATUS, type = CommandType.STRING, description = "the status of the storage pool")
|
||||
private String status;
|
||||
|
||||
@Parameter(name = ApiConstants.STORAGE_CUSTOM_STATS, type = CommandType.BOOLEAN, description = "If true, lists the custom stats of the storage pool", since = "4.18.1")
|
||||
private Boolean customStats;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -108,6 +110,10 @@ public class ListStoragePoolsCmd extends BaseListCmd {
|
|||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Boolean getCustomStats() {
|
||||
return customStats != null && customStats;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
description = "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. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST(via POST body), you can send up to 1MB of data after base64 encoding." +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576,
|
||||
since = "4.18.0")
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd {
|
|||
description = "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. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST(via POST body), you can send up to 1MB of data after base64 encoding." +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576,
|
||||
since = "4.18.0")
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.configuration.ResourceCount;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "updateResourceCount", description = "Recalculate and update resource count for an account or domain.", responseObject = ResourceCountResponse.class,
|
||||
@APICommand(name = "updateResourceCount",
|
||||
description = "Recalculate and update resource count for an account or domain. This also executes some " +
|
||||
"cleanup tasks before calculating resource counts.",
|
||||
responseObject = ResourceCountResponse.class,
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class UpdateResourceCountCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateResourceCountCmd.class.getName());
|
||||
|
|
|
|||
|
|
@ -74,7 +74,14 @@ public class RegisterUserDataCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "an optional project for the userdata")
|
||||
private Long projectId;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA, type = CommandType.STRING, required = true, description = "Userdata content", length = 1048576)
|
||||
@Parameter(name = ApiConstants.USER_DATA,
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "Base64 encoded userdata content. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576)
|
||||
private String userData;
|
||||
|
||||
@Parameter(name = ApiConstants.PARAMS, type = CommandType.STRING, description = "comma separated list of variables declared in userdata content")
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.cloudstack.acl.RoleType;
|
|||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiArgValidator;
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiConstants.IoDriverPolicy;
|
||||
|
|
@ -99,7 +100,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, required = true, description = "the ID of the template for the virtual machine")
|
||||
private Long templateId;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "host name for the virtual machine")
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "host name for the virtual machine", validations = {ApiArgValidator.RFCComplianceDomainName})
|
||||
private String name;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_NAME, type = CommandType.STRING, description = "an optional user generated name for the virtual machine")
|
||||
|
|
@ -152,7 +153,11 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||
private String hypervisor;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA, type = CommandType.STRING,
|
||||
description = "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. Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 1MB of data after base64 encoding.",
|
||||
description = "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. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576)
|
||||
private String userData;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ResetVMUserDataCmd extends BaseCmd implements UserCmd {
|
|||
description = "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. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST(via POST body), you can send up to 1MB of data after base64 encoding." +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576)
|
||||
private String userData;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import org.apache.cloudstack.api.ApiArgValidator;
|
||||
import org.apache.cloudstack.api.response.UserDataResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -86,7 +88,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction,
|
|||
description = "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. " +
|
||||
"Using HTTP GET (via querystring), you can send up to 4KB of data after base64 encoding. " +
|
||||
"Using HTTP POST(via POST body), you can send up to 1MB of data after base64 encoding." +
|
||||
"Using HTTP POST (via POST body), you can send up to 1MB of data after base64 encoding. " +
|
||||
"You also need to change vm.userdata.max.length value",
|
||||
length = 1048576,
|
||||
since = "4.16.0")
|
||||
|
|
@ -106,7 +108,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction,
|
|||
description = "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory. This can be updated only when dynamic scaling is enabled on template, service offering and the corresponding global setting")
|
||||
protected Boolean isDynamicallyScalable;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "new host name of the vm. The VM has to be stopped/started for this update to take affect", since = "4.4")
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "new host name of the vm. The VM has to be stopped/started for this update to take affect", validations = {ApiArgValidator.RFCComplianceDomainName}, since = "4.4")
|
||||
private String name;
|
||||
|
||||
@Parameter(name = ApiConstants.INSTANCE_NAME, type = CommandType.STRING, description = "instance name of the user vm", since = "4.4", authorized = {RoleType.Admin})
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
private Map<String, String> counterParams;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA)
|
||||
@Param(description = "Base 64 encoded VM user data")
|
||||
@Param(description = "Base64 encoded VM user data")
|
||||
private String userData;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA_ID) @Param(description="the id of userdata used for the VM", since = "4.18.1")
|
||||
|
|
|
|||
|
|
@ -208,6 +208,14 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
@Param(description = "comma-separated list of tags for the host")
|
||||
private String hostTags;
|
||||
|
||||
@SerializedName("explicithosttags")
|
||||
@Param(description = "comma-separated list of explicit host tags for the host", since = "4.18.1")
|
||||
private String explicitHostTags;
|
||||
|
||||
@SerializedName("implicithosttags")
|
||||
@Param(description = "comma-separated list of implicit host tags for the host", since = "4.18.1")
|
||||
private String implicitHostTags;
|
||||
|
||||
@SerializedName("hasenoughcapacity")
|
||||
@Param(description = "true if this host has enough CPU and RAM capacity to migrate a VM to it, false otherwise")
|
||||
private Boolean hasEnoughCapacity;
|
||||
|
|
@ -414,6 +422,14 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public void setExplicitHostTags(String explicitHostTags) {
|
||||
this.explicitHostTags = explicitHostTags;
|
||||
}
|
||||
|
||||
public void setImplicitHostTags(String implicitHostTags) {
|
||||
this.implicitHostTags = implicitHostTags;
|
||||
}
|
||||
|
||||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,6 +221,14 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
@Param(description = "comma-separated list of tags for the host")
|
||||
private String hostTags;
|
||||
|
||||
@SerializedName("explicithosttags")
|
||||
@Param(description = "comma-separated list of explicit host tags for the host", since = "4.18.1")
|
||||
private String explicitHostTags;
|
||||
|
||||
@SerializedName("implicithosttags")
|
||||
@Param(description = "comma-separated list of implicit host tags for the host", since = "4.18.1")
|
||||
private String implicitHostTags;
|
||||
|
||||
@SerializedName("hasenoughcapacity")
|
||||
@Param(description = "true if this host has enough CPU and RAM capacity to migrate a VM to it, false otherwise")
|
||||
private Boolean hasEnoughCapacity;
|
||||
|
|
@ -454,6 +462,22 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public String getExplicitHostTags() {
|
||||
return explicitHostTags;
|
||||
}
|
||||
|
||||
public void setExplicitHostTags(String explicitHostTags) {
|
||||
this.explicitHostTags = explicitHostTags;
|
||||
}
|
||||
|
||||
public String getImplicitHostTags() {
|
||||
return implicitHostTags;
|
||||
}
|
||||
|
||||
public void setImplicitHostTags(String implicitHostTags) {
|
||||
this.implicitHostTags = implicitHostTags;
|
||||
}
|
||||
|
||||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.cloudstack.api.response;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
public class HostTagResponse extends BaseResponse {
|
||||
|
|
@ -34,6 +35,10 @@ public class HostTagResponse extends BaseResponse {
|
|||
@Param(description = "the name of the host tag")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.IS_IMPLICIT)
|
||||
@Param(description = "true if the host tag is implicit", since = "4.18.1")
|
||||
private boolean isImplicit;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -57,4 +62,12 @@ public class HostTagResponse extends BaseResponse {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isImplicit() {
|
||||
return isImplicit;
|
||||
}
|
||||
|
||||
public void setImplicit(boolean implicit) {
|
||||
isImplicit = implicit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
// 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 PurgeExpungedResourcesResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_COUNT)
|
||||
@Param(description = "The count of the purged expunged resources")
|
||||
private Long resourceCount;
|
||||
|
||||
public Long getResourceCount() {
|
||||
return resourceCount;
|
||||
}
|
||||
|
||||
public void setResourceCount(Long resourceCount) {
|
||||
this.resourceCount = resourceCount;
|
||||
}
|
||||
}
|
||||
|
|
@ -230,6 +230,10 @@ public class ServiceOfferingResponse extends BaseResponseWithAnnotations {
|
|||
@Param(description = "true if virtual machine root disk will be encrypted on storage", since = "4.18")
|
||||
private Boolean encryptRoot;
|
||||
|
||||
@SerializedName(ApiConstants.PURGE_RESOURCES)
|
||||
@Param(description = "Whether to cleanup VM and its associated resource upon expunge", since = "4.18.1")
|
||||
private Boolean purgeResources;
|
||||
|
||||
public ServiceOfferingResponse() {
|
||||
}
|
||||
|
||||
|
|
@ -543,4 +547,8 @@ public class ServiceOfferingResponse extends BaseResponseWithAnnotations {
|
|||
}
|
||||
|
||||
public void setEncryptRoot(Boolean encrypt) { this.encryptRoot = encrypt; }
|
||||
|
||||
public void setPurgeResources(Boolean purgeResources) {
|
||||
this.purgeResources = purgeResources;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ public class StoragePoolResponse extends BaseResponseWithAnnotations {
|
|||
@Param(description = "total min IOPS currently in use by volumes")
|
||||
private Long allocatedIops;
|
||||
|
||||
@SerializedName(ApiConstants.STORAGE_CUSTOM_STATS)
|
||||
@Param(description = "the storage pool custom stats", since = "4.18.1")
|
||||
private Map<String, String> customStats;
|
||||
|
||||
@SerializedName("tags")
|
||||
@Param(description = "the tags for the storage pool")
|
||||
private String tags;
|
||||
|
|
@ -296,6 +300,14 @@ public class StoragePoolResponse extends BaseResponseWithAnnotations {
|
|||
this.allocatedIops = allocatedIops;
|
||||
}
|
||||
|
||||
public Map<String, String> getCustomStats() {
|
||||
return customStats;
|
||||
}
|
||||
|
||||
public void setCustomStats(Map<String, String> customStats) {
|
||||
this.customStats = customStats;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class VMUserDataResponse extends BaseResponse {
|
|||
private String vmId;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA)
|
||||
@Param(description = "Base 64 encoded VM user data")
|
||||
@Param(description = "Base64 encoded VM user data")
|
||||
private String userData;
|
||||
|
||||
public void setUserData(String userData) {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ public interface CAManager extends CAService, Configurable, PluggableService {
|
|||
"15",
|
||||
"The number of days before expiry of a client certificate, the validations are checked. Admins are alerted when auto-renewal is not allowed, otherwise auto-renewal is attempted.", true, ConfigKey.Scope.Cluster);
|
||||
|
||||
|
||||
ConfigKey<String> CertManagementCustomSubjectAlternativeName = new ConfigKey<>("Advanced", String.class,
|
||||
"ca.framework.cert.management.custom.san",
|
||||
"cloudstack.internal",
|
||||
"The custom Subject Alternative Name that will be added to the management server certificate. " +
|
||||
"The actual implementation will depend on the configured CA provider.",
|
||||
false);
|
||||
|
||||
/**
|
||||
* Returns a list of available CA provider plugins
|
||||
* @return returns list of CAProvider
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
// 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.resource;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.resource.PurgeExpungedResourcesCmd;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface ResourceCleanupService {
|
||||
int MINIMUM_EXPUNGED_RESOURCE_PURGE_JOB_DELAY_IN_SECONDS = 3 * 60;
|
||||
ConfigKey<Boolean> ExpungedResourcePurgeEnabled = new ConfigKey<>("Advanced", Boolean.class,
|
||||
"expunged.resources.purge.enabled", "false",
|
||||
"Whether to run a background task to purge the DB records of the expunged resources",
|
||||
false, ConfigKey.Scope.Global);
|
||||
ConfigKey<String> ExpungedResourcePurgeResources = new ConfigKey<>("Advanced", String.class,
|
||||
"expunged.resources.purge.resources", "",
|
||||
"A comma-separated list of resource types that will be considered by the background task " +
|
||||
"to purge the DB records of the expunged resources. Currently only VirtualMachine is supported. " +
|
||||
"An empty value will result in considering all resource types for purging",
|
||||
false, ConfigKey.Scope.Global);
|
||||
ConfigKey<Integer> ExpungedResourcesPurgeInterval = new ConfigKey<>("Advanced", Integer.class,
|
||||
"expunged.resources.purge.interval", "86400",
|
||||
"Interval (in seconds) for the background task to purge the DB records of the expunged resources",
|
||||
false);
|
||||
ConfigKey<Integer> ExpungedResourcesPurgeDelay = new ConfigKey<>("Advanced", Integer.class,
|
||||
"expunged.resources.purge.delay", "300",
|
||||
"Initial delay (in seconds) to start the background task to purge the DB records of the " +
|
||||
"expunged resources task", false);
|
||||
ConfigKey<Integer> ExpungedResourcesPurgeBatchSize = new ConfigKey<>("Advanced", Integer.class,
|
||||
"expunged.resources.purge.batch.size", "50",
|
||||
"Batch size to be used during purging of the DB records of the expunged resources",
|
||||
true);
|
||||
ConfigKey<String> ExpungedResourcesPurgeStartTime = new ConfigKey<>("Advanced", String.class,
|
||||
"expunged.resources.purge.start.time", "",
|
||||
"Start time to be used by the background task to purge the DB records of the expunged " +
|
||||
"resources. Use format \"yyyy-MM-dd\" or \"yyyy-MM-dd HH:mm:ss\"", true);
|
||||
ConfigKey<Integer> ExpungedResourcesPurgeKeepPastDays = new ConfigKey<>("Advanced", Integer.class,
|
||||
"expunged.resources.purge.keep.past.days", "30",
|
||||
"The number of days in the past from the execution time of the background task to purge " +
|
||||
"the DB records of the expunged resources for which the expunged resources must not be purged. " +
|
||||
"To enable purging DB records of the expunged resource till the execution of the background " +
|
||||
"task, set the value to zero.", true);
|
||||
ConfigKey<Integer> ExpungedResourcePurgeJobDelay = new ConfigKey<>("Advanced", Integer.class,
|
||||
"expunged.resource.purge.job.delay",
|
||||
String.valueOf(MINIMUM_EXPUNGED_RESOURCE_PURGE_JOB_DELAY_IN_SECONDS),
|
||||
String.format("Delay (in seconds) to execute the purging of the DB records of an expunged resource " +
|
||||
"initiated by the configuration in the offering. Minimum value should be %d seconds " +
|
||||
"and if a lower value is set then the minimum value will be used",
|
||||
MINIMUM_EXPUNGED_RESOURCE_PURGE_JOB_DELAY_IN_SECONDS),
|
||||
true);
|
||||
|
||||
enum ResourceType {
|
||||
VirtualMachine
|
||||
}
|
||||
|
||||
long purgeExpungedResources(PurgeExpungedResourcesCmd cmd);
|
||||
void purgeExpungedVmResourcesLaterIfNeeded(VirtualMachine vm);
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
|
||||
import com.cloud.configuration.Resource;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* an interface defining an {code}AutoClosable{code} reservation object
|
||||
*/
|
||||
|
|
@ -39,4 +41,6 @@ ResourceReservation extends InternalIdentity {
|
|||
String getTag();
|
||||
|
||||
Long getReservedAmount();
|
||||
|
||||
Date getCreated();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,16 @@
|
|||
package org.apache.cloudstack.userdata;
|
||||
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface UserDataManager extends Manager, Configurable {
|
||||
String VM_USERDATA_MAX_LENGTH_STRING = "vm.userdata.max.length";
|
||||
ConfigKey<Integer> VM_USERDATA_MAX_LENGTH = new ConfigKey<>("Advanced", Integer.class, VM_USERDATA_MAX_LENGTH_STRING, "32768",
|
||||
"Max length of vm userdata after base64 encoding. Default is 32768 and maximum is 1048576", true);
|
||||
|
||||
String concatenateUserData(String userdata1, String userdata2, String userdataProvider);
|
||||
String validateUserData(String userData, BaseCmd.HTTPMethod httpmethod);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.offering;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateServiceOfferingCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private CreateServiceOfferingCmd createServiceOfferingCmd;
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesNoOrNullValue() {
|
||||
Assert.assertFalse(createServiceOfferingCmd.isPurgeResources());
|
||||
ReflectionTestUtils.setField(createServiceOfferingCmd, "purgeResources", false);
|
||||
Assert.assertFalse(createServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesFalse() {
|
||||
ReflectionTestUtils.setField(createServiceOfferingCmd, "purgeResources", false);
|
||||
Assert.assertFalse(createServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesTrue() {
|
||||
ReflectionTestUtils.setField(createServiceOfferingCmd, "purgeResources", true);
|
||||
Assert.assertTrue(createServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.offering;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UpdateServiceOfferingCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private UpdateServiceOfferingCmd updateServiceOfferingCmd;
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesNoOrNullValue() {
|
||||
Assert.assertFalse(updateServiceOfferingCmd.isPurgeResources());
|
||||
ReflectionTestUtils.setField(updateServiceOfferingCmd, "purgeResources", false);
|
||||
Assert.assertFalse(updateServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesFalse() {
|
||||
ReflectionTestUtils.setField(updateServiceOfferingCmd, "purgeResources", false);
|
||||
Assert.assertFalse(updateServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPurgeResourcesTrue() {
|
||||
ReflectionTestUtils.setField(updateServiceOfferingCmd, "purgeResources", true);
|
||||
Assert.assertTrue(updateServiceOfferingCmd.isPurgeResources());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.resource;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.PurgeExpungedResourcesResponse;
|
||||
import org.apache.cloudstack.resource.ResourceCleanupService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PurgeExpungedResourcesCmdTest {
|
||||
@Mock
|
||||
ResourceCleanupService resourceCleanupService;
|
||||
|
||||
@Spy
|
||||
@InjectMocks
|
||||
PurgeExpungedResourcesCmd spyCmd = Mockito.spy(new PurgeExpungedResourcesCmd());
|
||||
|
||||
@Test
|
||||
public void testGetResourceType() {
|
||||
PurgeExpungedResourcesCmd cmd = new PurgeExpungedResourcesCmd();
|
||||
assertNull(cmd.getResourceType());
|
||||
ReflectionTestUtils.setField(cmd, "resourceType", ResourceCleanupService.ResourceType.VirtualMachine.toString());
|
||||
Assert.assertEquals(ResourceCleanupService.ResourceType.VirtualMachine.toString(), cmd.getResourceType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBatchSize() {
|
||||
PurgeExpungedResourcesCmd cmd = new PurgeExpungedResourcesCmd();
|
||||
assertNull(cmd.getBatchSize());
|
||||
Long batchSize = 100L;
|
||||
ReflectionTestUtils.setField(cmd, "batchSize", batchSize);
|
||||
Assert.assertEquals(batchSize, cmd.getBatchSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStartDate() {
|
||||
PurgeExpungedResourcesCmd cmd = new PurgeExpungedResourcesCmd();
|
||||
assertNull(cmd.getStartDate());
|
||||
Date date = new Date();
|
||||
ReflectionTestUtils.setField(cmd, "startDate", date);
|
||||
Assert.assertEquals(date, cmd.getStartDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndDate() {
|
||||
PurgeExpungedResourcesCmd cmd = new PurgeExpungedResourcesCmd();
|
||||
assertNull(cmd.getEndDate());
|
||||
Date date = new Date();
|
||||
ReflectionTestUtils.setField(cmd, "endDate", date);
|
||||
Assert.assertEquals(date, cmd.getEndDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
final PurgeExpungedResourcesResponse[] executeResponse = new PurgeExpungedResourcesResponse[1];
|
||||
Long result = 100L;
|
||||
Mockito.when(resourceCleanupService.purgeExpungedResources(Mockito.any())).thenReturn(result);
|
||||
Mockito.doAnswer((Answer<Void>) invocation -> {
|
||||
executeResponse[0] = (PurgeExpungedResourcesResponse)invocation.getArguments()[0];
|
||||
return null;
|
||||
}).when(spyCmd).setResponseObject(Mockito.any());
|
||||
spyCmd.execute();
|
||||
PurgeExpungedResourcesResponse response = executeResponse[0];
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(result, response.getResourceCount());
|
||||
}
|
||||
|
||||
@Test(expected = ServerApiException.class)
|
||||
public void testExecuteException() {
|
||||
Mockito.doThrow(CloudRuntimeException.class).when(resourceCleanupService).purgeExpungedResources(Mockito.any());
|
||||
spyCmd.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -98,9 +98,9 @@ under the License.
|
|||
|
||||
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
<param name="Threshold" value="INFO"/>
|
||||
<param name="Threshold" value="OFF"/>
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p [%c{1.}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
|
||||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1.}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>-
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
public class GetVolumeStatAnswer extends Answer {
|
||||
String poolUuid;
|
||||
StoragePoolType poolType;
|
||||
String volumePath;
|
||||
long size = 0;
|
||||
long virtualSize = 0;
|
||||
|
||||
public GetVolumeStatAnswer(GetVolumeStatCommand cmd, long size, long virtualSize) {
|
||||
super(cmd, true, "");
|
||||
this.poolUuid = cmd.getPoolUuid();
|
||||
this.poolType = cmd.getPoolType();
|
||||
this.volumePath = cmd.getVolumePath();
|
||||
this.size = size;
|
||||
this.virtualSize = virtualSize;
|
||||
}
|
||||
|
||||
public GetVolumeStatAnswer(GetVolumeStatCommand cmd, boolean success, String details) {
|
||||
super(cmd, success, details);
|
||||
}
|
||||
|
||||
protected GetVolumeStatAnswer() {
|
||||
//no-args constructor for json serialization-deserialization
|
||||
}
|
||||
|
||||
public String getPoolUuid() {
|
||||
return poolUuid;
|
||||
}
|
||||
|
||||
public void setPoolUuid(String poolUuid) {
|
||||
this.poolUuid = poolUuid;
|
||||
}
|
||||
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public void setPoolType(StoragePoolType poolType) {
|
||||
this.poolType = poolType;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public long getVirtualSize() {
|
||||
return virtualSize;
|
||||
}
|
||||
|
||||
public void setVirtualSize(long virtualSize) {
|
||||
this.virtualSize = virtualSize;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return "GetVolumeStatAnswer [poolUuid=" + poolUuid + ", poolType=" + poolType + ", volumePath=" + volumePath + ", size=" + size + ", virtualSize=" + virtualSize + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
public class GetVolumeStatCommand extends Command {
|
||||
String volumePath;
|
||||
StoragePoolType poolType;
|
||||
String poolUuid;
|
||||
|
||||
protected GetVolumeStatCommand() {
|
||||
}
|
||||
|
||||
public GetVolumeStatCommand(String volumePath, StoragePoolType poolType, String poolUuid) {
|
||||
this.volumePath = volumePath;
|
||||
this.poolType = poolType;
|
||||
this.poolUuid = poolUuid;
|
||||
}
|
||||
|
||||
public String getVolumePath() {
|
||||
return volumePath;
|
||||
}
|
||||
|
||||
public void setVolumePath(String volumePath) {
|
||||
this.volumePath = volumePath;
|
||||
}
|
||||
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public void setPoolType(StoragePoolType poolType) {
|
||||
this.poolType = poolType;
|
||||
}
|
||||
|
||||
public String getPoolUuid() {
|
||||
return poolUuid;
|
||||
}
|
||||
|
||||
public void setPoolUuid(String storeUuid) {
|
||||
this.poolUuid = storeUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return "GetVolumeStatCommand [volumePath=" + volumePath + ", poolType=" + poolType + ", poolUuid=" + poolUuid + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@ public class MigrateCommand extends Command {
|
|||
private boolean executeInSequence = false;
|
||||
private List<MigrateDiskInfo> migrateDiskInfoList = new ArrayList<>();
|
||||
private Map<String, DpdkTO> dpdkInterfaceMapping = new HashMap<>();
|
||||
|
||||
private int newVmCpuShares;
|
||||
|
||||
Map<String, Boolean> vlanToPersistenceMap = new HashMap<>();
|
||||
|
||||
public Map<String, DpdkTO> getDpdkInterfaceMapping() {
|
||||
|
|
@ -138,6 +141,14 @@ public class MigrateCommand extends Command {
|
|||
this.migrateDiskInfoList = migrateDiskInfoList;
|
||||
}
|
||||
|
||||
public int getNewVmCpuShares() {
|
||||
return newVmCpuShares;
|
||||
}
|
||||
|
||||
public void setNewVmCpuShares(int newVmCpuShares) {
|
||||
this.newVmCpuShares = newVmCpuShares;
|
||||
}
|
||||
|
||||
public static class MigrateDiskInfo {
|
||||
public enum DiskType {
|
||||
FILE, BLOCK;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public class PrepareForMigrationAnswer extends Answer {
|
|||
|
||||
private Map<String, DpdkTO> dpdkInterfaceMapping = new HashMap<>();
|
||||
|
||||
private Integer newVmCpuShares = null;
|
||||
|
||||
protected PrepareForMigrationAnswer() {
|
||||
}
|
||||
|
||||
|
|
@ -50,4 +52,12 @@ public class PrepareForMigrationAnswer extends Answer {
|
|||
public Map<String, DpdkTO> getDpdkInterfaceMapping() {
|
||||
return this.dpdkInterfaceMapping;
|
||||
}
|
||||
|
||||
public Integer getNewVmCpuShares() {
|
||||
return newVmCpuShares;
|
||||
}
|
||||
|
||||
public void setNewVmCpuShares(Integer newVmCpuShares) {
|
||||
this.newVmCpuShares = newVmCpuShares;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PrepareStorageClientAnswer extends Answer {
|
||||
Map<String, String> detailsMap;
|
||||
|
||||
public PrepareStorageClientAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrepareStorageClientAnswer(Command command, boolean success, Map<String, String> detailsMap) {
|
||||
super(command, success, "");
|
||||
this.detailsMap = detailsMap;
|
||||
}
|
||||
|
||||
public PrepareStorageClientAnswer(Command command, boolean success, String details) {
|
||||
super(command, success, details);
|
||||
}
|
||||
|
||||
public Map<String, String> getDetailsMap() {
|
||||
return detailsMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
public class PrepareStorageClientCommand extends Command {
|
||||
private StoragePoolType poolType;
|
||||
private String poolUuid;
|
||||
private Map<String, String> details;
|
||||
|
||||
public PrepareStorageClientCommand() {
|
||||
}
|
||||
|
||||
public PrepareStorageClientCommand(StoragePoolType poolType, String poolUuid, Map<String, String> details) {
|
||||
this.poolType = poolType;
|
||||
this.poolUuid = poolUuid;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public String getPoolUuid() {
|
||||
return poolUuid;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
}
|
||||
|
|
@ -174,6 +174,10 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
this.hostTags.add(hostTag);
|
||||
}
|
||||
|
||||
public void setHostTags(List<String> hostTags) {
|
||||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
|
||||
return groupDetails;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//
|
||||
// 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
|
||||
|
|
@ -14,17 +15,20 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.api.query.dao;
|
||||
//
|
||||
|
||||
import java.util.List;
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
public class UnprepareStorageClientAnswer extends Answer {
|
||||
public UnprepareStorageClientAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
import com.cloud.api.query.vo.HostTagVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
public UnprepareStorageClientAnswer(Command command, boolean success) {
|
||||
super(command, success, "");
|
||||
}
|
||||
|
||||
public interface HostTagDao extends GenericDao<HostTagVO, Long> {
|
||||
HostTagResponse newHostTagResponse(HostTagVO hostTag);
|
||||
|
||||
List<HostTagVO> searchByIds(Long... hostTagIds);
|
||||
public UnprepareStorageClientAnswer(Command command, boolean success, String details) {
|
||||
super(command, success, details);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
//
|
||||
// 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
|
||||
|
|
@ -14,48 +15,34 @@
|
|||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.api.query.vo;
|
||||
//
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
/**
|
||||
* Storage Tags DB view.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "host_tags")
|
||||
public class HostTagVO extends BaseViewVO implements InternalIdentity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class UnprepareStorageClientCommand extends Command {
|
||||
private StoragePoolType poolType;
|
||||
private String poolUuid;
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
public UnprepareStorageClientCommand() {
|
||||
}
|
||||
|
||||
@Column(name = "tag")
|
||||
private String name;
|
||||
|
||||
@Column(name = "host_id")
|
||||
long hostId;
|
||||
public UnprepareStorageClientCommand(StoragePoolType poolType, String poolUuid) {
|
||||
this.poolType = poolType;
|
||||
this.poolUuid = poolUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(long hostId) {
|
||||
this.hostId = hostId;
|
||||
public String getPoolUuid() {
|
||||
return poolUuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
package com.cloud.resource;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public abstract class CommandWrapper<T extends Command, A extends Answer, R extends ServerResource> {
|
||||
protected Logger logger = Logger.getLogger(getClass());
|
||||
|
|
@ -32,4 +35,26 @@ public abstract class CommandWrapper<T extends Command, A extends Answer, R exte
|
|||
* @return A and the Answer from the command.
|
||||
*/
|
||||
public abstract A execute(T command, R serverResource);
|
||||
|
||||
protected String sanitizeBashCommandArgument(String input) {
|
||||
StringBuilder sanitized = new StringBuilder();
|
||||
for (char c : input.toCharArray()) {
|
||||
if ("\\\"'`$|&;()<>*?![]{}~".indexOf(c) != -1) {
|
||||
sanitized.append('\\');
|
||||
}
|
||||
sanitized.append(c);
|
||||
}
|
||||
return sanitized.toString();
|
||||
}
|
||||
|
||||
public void removeDpdkPort(String portToRemove) {
|
||||
logger.debug("Removing DPDK port: " + portToRemove);
|
||||
int port;
|
||||
try {
|
||||
port = Integer.valueOf(portToRemove);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new CloudRuntimeException(String.format("Invalid DPDK port specified: '%s'", portToRemove));
|
||||
}
|
||||
Script.executeCommand("ovs-vsctl", "del-port", String.valueOf(port));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO {
|
|||
private DataStoreTO dataStore;
|
||||
private String name;
|
||||
private Long size;
|
||||
private Long usableSize;
|
||||
private String path;
|
||||
private Long volumeId;
|
||||
private String vmName;
|
||||
|
|
@ -161,6 +162,10 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO {
|
|||
return size;
|
||||
}
|
||||
|
||||
public Long getUsableSize() {
|
||||
return usableSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObjectType getObjectType() {
|
||||
return DataObjectType.VOLUME;
|
||||
|
|
@ -178,6 +183,10 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO {
|
|||
this.size = size;
|
||||
}
|
||||
|
||||
public void setUsableSize(Long usableSize) {
|
||||
this.usableSize = usableSize;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ override_dh_auto_install:
|
|||
install -m0644 packaging/systemd/$(PACKAGE)-management.service debian/$(PACKAGE)-management/lib/systemd/system/$(PACKAGE)-management.service
|
||||
install -m0644 packaging/systemd/$(PACKAGE)-management.default $(DESTDIR)/$(SYSCONFDIR)/default/$(PACKAGE)-management
|
||||
|
||||
install -D -m0644 server/target/conf/cloudstack-management.logrotate $(DESTDIR)/$(SYSCONFDIR)/logrotate.d/cloudstack-management
|
||||
|
||||
# cloudstack-ui
|
||||
mkdir $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/ui
|
||||
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-ui
|
||||
|
|
@ -155,6 +157,8 @@ override_dh_auto_install:
|
|||
install -m0644 packaging/systemd/$(PACKAGE)-usage.service debian/$(PACKAGE)-usage/lib/systemd/system/$(PACKAGE)-usage.service
|
||||
install -m0644 packaging/systemd/$(PACKAGE)-usage.default $(DESTDIR)/$(SYSCONFDIR)/default/$(PACKAGE)-usage
|
||||
|
||||
install -D -m0644 usage/target/transformed/cloudstack-usage.logrotate $(DESTDIR)/$(SYSCONFDIR)/logrotate.d/cloudstack-usage
|
||||
|
||||
# cloudstack-marvin
|
||||
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-marvin
|
||||
cp tools/marvin/dist/Marvin-*.tar.gz $(DESTDIR)/usr/share/$(PACKAGE)-marvin/
|
||||
|
|
|
|||
|
|
@ -344,4 +344,6 @@ public interface NetworkOrchestrationService {
|
|||
Pair<NicProfile, Integer> importNic(final String macAddress, int deviceId, final Network network, final Boolean isDefaultNic, final VirtualMachine vm, final Network.IpAddresses ipAddresses, boolean forced) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException;
|
||||
|
||||
void unmanageNics(VirtualMachineProfile vm);
|
||||
|
||||
void expungeLbVmRefs(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
|
|
@ -84,6 +86,22 @@ public interface PrimaryDataStoreDriver extends DataStoreDriver {
|
|||
*/
|
||||
boolean canProvideStorageStats();
|
||||
|
||||
/**
|
||||
* intended for managed storage
|
||||
* returns true if the storage can provide its custom stats
|
||||
*/
|
||||
default boolean poolProvidesCustomStorageStats() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* intended for managed storage
|
||||
* returns the custom stats if the storage can provide them
|
||||
*/
|
||||
default Map<String, String> getCustomStorageStats(StoragePool pool) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* intended for managed storage
|
||||
* returns the total capacity and used size in bytes
|
||||
|
|
@ -108,6 +126,14 @@ public interface PrimaryDataStoreDriver extends DataStoreDriver {
|
|||
*/
|
||||
boolean canHostAccessStoragePool(Host host, StoragePool pool);
|
||||
|
||||
/**
|
||||
* intended for managed storage
|
||||
* returns true if the host can prepare storage client to provide access the storage pool
|
||||
*/
|
||||
default boolean canHostPrepareStoragePoolAccess(Host host, StoragePool pool) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by storage pools which want to keep VMs' information
|
||||
* @return true if additional VM info is needed (intended for storage pools).
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.cloud.dc.VlanVO;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.impl.ConfigurationSubGroupVO;
|
||||
|
||||
import com.cloud.dc.ClusterVO;
|
||||
|
|
@ -61,9 +60,6 @@ public interface ConfigurationManager {
|
|||
public static final String MESSAGE_CREATE_VLAN_IP_RANGE_EVENT = "Message.CreateVlanIpRange.Event";
|
||||
public static final String MESSAGE_DELETE_VLAN_IP_RANGE_EVENT = "Message.DeleteVlanIpRange.Event";
|
||||
|
||||
static final String VM_USERDATA_MAX_LENGTH_STRING = "vm.userdata.max.length";
|
||||
static final ConfigKey<Integer> VM_USERDATA_MAX_LENGTH = new ConfigKey<>("Advanced", Integer.class, VM_USERDATA_MAX_LENGTH_STRING, "32768",
|
||||
"Max length of vm userdata after base64 decoding. Default is 32768 and maximum is 1048576", true);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
|
|
|
|||
|
|
@ -153,4 +153,5 @@ public interface HighAvailabilityManager extends Manager {
|
|||
String getHaTag();
|
||||
|
||||
DeploymentPlanner getHAPlanner();
|
||||
int expungeWorkItemsByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.cloud.storage;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||
|
|
@ -117,7 +118,7 @@ public interface StorageManager extends StorageService {
|
|||
"storage.pool.disk.wait",
|
||||
"Storage",
|
||||
"60",
|
||||
"Timeout (in secs) for the storage pool disk (of managed pool) to become available in the host. Currently only supported for PowerFlex.",
|
||||
"Timeout (in secs) for the storage pool disk (of managed pool) to become available in the host. Currently supported for PowerFlex only.",
|
||||
true,
|
||||
ConfigKey.Scope.StoragePool,
|
||||
null);
|
||||
|
|
@ -126,7 +127,7 @@ public interface StorageManager extends StorageService {
|
|||
"storage.pool.client.timeout",
|
||||
"Storage",
|
||||
"60",
|
||||
"Timeout (in secs) for the storage pool client connection timeout (for managed pools). Currently only supported for PowerFlex.",
|
||||
"Timeout (in secs) for the API client connection timeout of storage pool (for managed pools). Currently supported for PowerFlex only.",
|
||||
false,
|
||||
ConfigKey.Scope.StoragePool,
|
||||
null);
|
||||
|
|
@ -135,11 +136,20 @@ public interface StorageManager extends StorageService {
|
|||
"storage.pool.client.max.connections",
|
||||
"Storage",
|
||||
"100",
|
||||
"Maximum connections for the storage pool client (for managed pools). Currently only supported for PowerFlex.",
|
||||
"Maximum connections for the API client of storage pool (for managed pools). Currently supported for PowerFlex only.",
|
||||
false,
|
||||
ConfigKey.Scope.StoragePool,
|
||||
null);
|
||||
|
||||
ConfigKey<Integer> STORAGE_POOL_CONNECTED_CLIENTS_LIMIT = new ConfigKey<>(Integer.class,
|
||||
"storage.pool.connected.clients.limit",
|
||||
"Storage",
|
||||
"-1",
|
||||
"Maximum connected storage pool clients supported for the storage (for managed pools), <= 0 for unlimited (default: -1). Currently supported for PowerFlex only.",
|
||||
true,
|
||||
ConfigKey.Scope.StoragePool,
|
||||
null);
|
||||
|
||||
ConfigKey<String> STORAGE_POOL_IO_POLICY = new ConfigKey<>(String.class,
|
||||
"kvm.storage.pool.io.policy",
|
||||
"Storage",
|
||||
|
|
@ -248,6 +258,10 @@ public interface StorageManager extends StorageService {
|
|||
|
||||
boolean canPoolProvideStorageStats(StoragePool pool);
|
||||
|
||||
boolean poolProvidesCustomStorageStats(StoragePool pool);
|
||||
|
||||
Map<String, String> getCustomStorageStats(StoragePool pool);
|
||||
|
||||
/**
|
||||
* Checks if a host has running VMs that are using its local storage pool.
|
||||
* @return true if local storage is active on the host
|
||||
|
|
@ -284,6 +298,8 @@ public interface StorageManager extends StorageService {
|
|||
|
||||
boolean canHostAccessStoragePool(Host host, StoragePool pool);
|
||||
|
||||
boolean canHostPrepareStoragePoolAccess(Host host, StoragePool pool);
|
||||
|
||||
Host getHost(long hostId);
|
||||
|
||||
Host updateSecondaryStorage(long secStorageId, String newUrl);
|
||||
|
|
|
|||
|
|
@ -264,11 +264,13 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
|||
_offering = offering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCpuOvercommitRatio(Float cpuOvercommitRatio) {
|
||||
this.cpuOvercommitRatio = cpuOvercommitRatio;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMemoryOvercommitRatio(Float memoryOvercommitRatio) {
|
||||
this.memoryOvercommitRatio = memoryOvercommitRatio;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import javax.persistence.EntityExistsException;
|
|||
import com.cloud.configuration.Resource;
|
||||
import com.cloud.event.ActionEventUtils;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
|
|
@ -83,6 +84,7 @@ import org.apache.cloudstack.framework.messagebus.MessageHandler;
|
|||
import org.apache.cloudstack.jobs.JobInfo;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.cloudstack.reservation.dao.ReservationDao;
|
||||
import org.apache.cloudstack.resource.ResourceCleanupService;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
|
|
@ -389,6 +391,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
private DomainRouterJoinDao domainRouterJoinDao;
|
||||
@Inject
|
||||
private AnnotationDao annotationDao;
|
||||
@Inject
|
||||
ResourceCleanupService resourceCleanupService;
|
||||
|
||||
VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy(this);
|
||||
|
||||
|
|
@ -698,6 +702,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Expunged " + vm);
|
||||
}
|
||||
resourceCleanupService.purgeExpungedVmResourcesLaterIfNeeded(vm);
|
||||
}
|
||||
|
||||
protected void handleUnsuccessfulCommands(Commands cmds, VMInstanceVO vm) throws CloudRuntimeException {
|
||||
|
|
@ -1248,21 +1253,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
long destHostId = dest.getHost().getId();
|
||||
vm.setPodIdToDeployIn(dest.getPod().getId());
|
||||
final Long cluster_id = dest.getCluster().getId();
|
||||
final ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
||||
final ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
||||
final Long clusterId = dest.getCluster().getId();
|
||||
updateOverCommitRatioForVmProfile(vmProfile, clusterId);
|
||||
|
||||
if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO) == null &&
|
||||
(Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f)) {
|
||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, cluster_detail_cpu.getValue(), true);
|
||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, cluster_detail_ram.getValue(), true);
|
||||
} else if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO) != null) {
|
||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, cluster_detail_cpu.getValue(), true);
|
||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, cluster_detail_ram.getValue(), true);
|
||||
}
|
||||
|
||||
vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue()));
|
||||
vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue()));
|
||||
StartAnswer startAnswer = null;
|
||||
|
||||
try {
|
||||
|
|
@ -1277,7 +1270,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
resetVmNicsDeviceId(vm.getId());
|
||||
_networkMgr.prepare(vmProfile, dest, ctx);
|
||||
if (vm.getHypervisorType() != HypervisorType.BareMetal) {
|
||||
checkAndAttemptMigrateVmAcrossCluster(vm, cluster_id, dest.getStorageForDisks());
|
||||
checkAndAttemptMigrateVmAcrossCluster(vm, clusterId, dest.getStorageForDisks());
|
||||
volumeMgr.prepare(vmProfile, dest);
|
||||
}
|
||||
|
||||
|
|
@ -1481,6 +1474,27 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
}
|
||||
|
||||
private void updateOverCommitRatioForVmProfile(VirtualMachineProfile vmProfile, long clusterId) {
|
||||
final ClusterDetailsVO clusterDetailCpu = _clusterDetailsDao.findDetail(clusterId, VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
||||
final ClusterDetailsVO clusterDetailRam = _clusterDetailsDao.findDetail(clusterId, VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
||||
final float parsedClusterCpuDetailCpu = Float.parseFloat(clusterDetailCpu.getValue());
|
||||
final float parsedClusterDetailRam = Float.parseFloat(clusterDetailRam.getValue());
|
||||
UserVmDetailVO vmDetailCpu = userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
||||
UserVmDetailVO vmDetailRam = userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
||||
|
||||
if ((vmDetailCpu == null && parsedClusterCpuDetailCpu > 1f) ||
|
||||
(vmDetailCpu != null && Float.parseFloat(vmDetailCpu.getValue()) != parsedClusterCpuDetailCpu)) {
|
||||
userVmDetailsDao.addDetail(vmProfile.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, clusterDetailCpu.getValue(), true);
|
||||
}
|
||||
if ((vmDetailRam == null && parsedClusterDetailRam > 1f) ||
|
||||
(vmDetailRam != null && Float.parseFloat(vmDetailRam.getValue()) != parsedClusterDetailRam)) {
|
||||
userVmDetailsDao.addDetail(vmProfile.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, clusterDetailRam.getValue(), true);
|
||||
}
|
||||
|
||||
vmProfile.setCpuOvercommitRatio(Float.parseFloat(clusterDetailCpu.getValue()));
|
||||
vmProfile.setMemoryOvercommitRatio(Float.parseFloat(clusterDetailRam.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting pod id to null can result in migration of Volumes across pods. This is not desirable for VMs which
|
||||
* have a volume in Ready state (happens when a VM is shutdown and started again).
|
||||
|
|
@ -2762,6 +2776,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_networkMgr.prepareNicForMigration(profile, dest);
|
||||
volumeMgr.prepareForMigration(profile, dest);
|
||||
profile.setConfigDriveLabel(VmConfigDriveLabel.value());
|
||||
updateOverCommitRatioForVmProfile(profile, dest.getHost().getClusterId());
|
||||
|
||||
final VirtualMachineTO to = toVmTO(profile);
|
||||
final PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand(to);
|
||||
|
|
@ -2824,23 +2839,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
boolean migrated = false;
|
||||
Map<String, DpdkTO> dpdkInterfaceMapping = null;
|
||||
Map<String, DpdkTO> dpdkInterfaceMapping = new HashMap<>();
|
||||
try {
|
||||
final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
|
||||
Map<String, Boolean> vlanToPersistenceMap = getVlanToPersistenceMapForVM(vm.getId());
|
||||
final MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows, to, getExecuteInSequence(vm.getHypervisorType()));
|
||||
if (MapUtils.isNotEmpty(vlanToPersistenceMap)) {
|
||||
mc.setVlanToPersistenceMap(vlanToPersistenceMap);
|
||||
}
|
||||
|
||||
boolean kvmAutoConvergence = StorageManager.KvmAutoConvergence.value();
|
||||
mc.setAutoConvergence(kvmAutoConvergence);
|
||||
mc.setHostGuid(dest.getHost().getGuid());
|
||||
|
||||
dpdkInterfaceMapping = ((PrepareForMigrationAnswer) pfma).getDpdkInterfaceMapping();
|
||||
if (MapUtils.isNotEmpty(dpdkInterfaceMapping)) {
|
||||
mc.setDpdkInterfaceMapping(dpdkInterfaceMapping);
|
||||
}
|
||||
final MigrateCommand mc = buildMigrateCommand(vm, to, dest, pfma, dpdkInterfaceMapping);
|
||||
|
||||
try {
|
||||
final Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
|
||||
|
|
@ -2912,6 +2913,43 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and set parameters for the {@link MigrateCommand} used in the migration and scaling of VMs.
|
||||
*/
|
||||
protected MigrateCommand buildMigrateCommand(VMInstanceVO vmInstance, VirtualMachineTO virtualMachineTO, DeployDestination destination, Answer answer,
|
||||
Map<String, DpdkTO> dpdkInterfaceMapping) {
|
||||
final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vmInstance.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
|
||||
final MigrateCommand migrateCommand = new MigrateCommand(vmInstance.getInstanceName(), destination.getHost().getPrivateIpAddress(), isWindows, virtualMachineTO,
|
||||
getExecuteInSequence(vmInstance.getHypervisorType()));
|
||||
|
||||
Map<String, Boolean> vlanToPersistenceMap = getVlanToPersistenceMapForVM(vmInstance.getId());
|
||||
if (MapUtils.isNotEmpty(vlanToPersistenceMap)) {
|
||||
s_logger.debug(String.format("Setting VLAN persistence to [%s] as part of migrate command for VM [%s].", new Gson().toJson(vlanToPersistenceMap), virtualMachineTO));
|
||||
migrateCommand.setVlanToPersistenceMap(vlanToPersistenceMap);
|
||||
}
|
||||
|
||||
migrateCommand.setAutoConvergence(StorageManager.KvmAutoConvergence.value());
|
||||
migrateCommand.setHostGuid(destination.getHost().getGuid());
|
||||
|
||||
PrepareForMigrationAnswer prepareForMigrationAnswer = (PrepareForMigrationAnswer) answer;
|
||||
|
||||
Map<String, DpdkTO> answerDpdkInterfaceMapping = prepareForMigrationAnswer.getDpdkInterfaceMapping();
|
||||
if (MapUtils.isNotEmpty(answerDpdkInterfaceMapping) && dpdkInterfaceMapping != null) {
|
||||
s_logger.debug(String.format("Setting DPDK interface mapping to [%s] as part of migrate command for VM [%s].", new Gson().toJson(vlanToPersistenceMap),
|
||||
virtualMachineTO));
|
||||
dpdkInterfaceMapping.putAll(answerDpdkInterfaceMapping);
|
||||
migrateCommand.setDpdkInterfaceMapping(dpdkInterfaceMapping);
|
||||
}
|
||||
|
||||
Integer newVmCpuShares = prepareForMigrationAnswer.getNewVmCpuShares();
|
||||
if (newVmCpuShares != null) {
|
||||
s_logger.debug(String.format("Setting CPU shares to [%d] as part of migrate command for VM [%s].", newVmCpuShares, virtualMachineTO));
|
||||
migrateCommand.setNewVmCpuShares(newVmCpuShares);
|
||||
}
|
||||
|
||||
return migrateCommand;
|
||||
}
|
||||
|
||||
private void updateVmPod(VMInstanceVO vm, long dstHostId) {
|
||||
// update the VMs pod
|
||||
HostVO host = _hostDao.findById(dstHostId);
|
||||
|
|
@ -4433,16 +4471,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
boolean migrated = false;
|
||||
try {
|
||||
Map<String, Boolean> vlanToPersistenceMap = getVlanToPersistenceMapForVM(vm.getId());
|
||||
final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
|
||||
final MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows, to, getExecuteInSequence(vm.getHypervisorType()));
|
||||
if (MapUtils.isNotEmpty(vlanToPersistenceMap)) {
|
||||
mc.setVlanToPersistenceMap(vlanToPersistenceMap);
|
||||
}
|
||||
|
||||
boolean kvmAutoConvergence = StorageManager.KvmAutoConvergence.value();
|
||||
mc.setAutoConvergence(kvmAutoConvergence);
|
||||
mc.setHostGuid(dest.getHost().getGuid());
|
||||
final MigrateCommand mc = buildMigrateCommand(vm, to, dest, pfma, null);
|
||||
|
||||
try {
|
||||
final Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
|
||||
|
|
|
|||
|
|
@ -770,6 +770,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
continue;
|
||||
}
|
||||
|
||||
// Ensure cidr size is equal to 64 for
|
||||
// - networks other than shared networks
|
||||
// - shared networks with SLAAC V6 only
|
||||
if (predefined != null && StringUtils.isNotBlank(predefined.getIp6Cidr()) &&
|
||||
(!GuestType.Shared.equals(offering.getGuestType()) || guru.isSlaacV6Only())) {
|
||||
_networkModel.checkIp6CidrSizeEqualTo64(predefined.getIp6Cidr());
|
||||
}
|
||||
|
||||
if (network.getId() != -1) {
|
||||
if (network instanceof NetworkVO) {
|
||||
networks.add((NetworkVO) network);
|
||||
|
|
@ -2678,8 +2686,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
}
|
||||
}
|
||||
|
||||
if (ipv6 && NetUtils.getIp6CidrSize(ip6Cidr) != 64) {
|
||||
throw new InvalidParameterValueException("IPv6 subnet should be exactly 64-bits in size");
|
||||
if (ipv6 && !GuestType.Shared.equals(ntwkOff.getGuestType())) {
|
||||
_networkModel.checkIp6CidrSizeEqualTo64(ip6Cidr);
|
||||
}
|
||||
|
||||
//TODO(VXLAN): Support VNI specified
|
||||
|
|
@ -4666,6 +4674,19 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expungeLbVmRefs(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(networkElements) || CollectionUtils.isEmpty(vmIds)) {
|
||||
return;
|
||||
}
|
||||
for (NetworkElement element : networkElements) {
|
||||
if (element instanceof LoadBalancingServiceProvider) {
|
||||
LoadBalancingServiceProvider lbProvider = (LoadBalancingServiceProvider)element;
|
||||
lbProvider.expungeLbVmRefs(vmIds, batchSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return NetworkOrchestrationService.class.getSimpleName();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ public class HostTagVO implements InternalIdentity {
|
|||
@Column(name = "tag")
|
||||
private String tag;
|
||||
|
||||
@Column(name = "is_implicit")
|
||||
private boolean isImplicit = false;
|
||||
|
||||
protected HostTagVO() {
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +62,14 @@ public class HostTagVO implements InternalIdentity {
|
|||
this.tag = tag;
|
||||
}
|
||||
|
||||
public void setIsImplicit(boolean isImplicit) {
|
||||
this.isImplicit = isImplicit;
|
||||
}
|
||||
|
||||
public boolean getIsImplicit() {
|
||||
return isImplicit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
// under the License.
|
||||
package com.cloud.host;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -44,6 +44,7 @@ import javax.persistence.Transient;
|
|||
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
|
|
@ -752,27 +753,48 @@ public class HostVO implements Host {
|
|||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public boolean checkHostServiceOfferingAndTemplateTags(ServiceOffering serviceOffering, VirtualMachineTemplate template) {
|
||||
if (serviceOffering == null || template == null) {
|
||||
return false;
|
||||
}
|
||||
private Set<String> getHostServiceOfferingAndTemplateStrictTags(ServiceOffering serviceOffering, VirtualMachineTemplate template, Set<String> strictHostTags) {
|
||||
if (StringUtils.isEmpty(serviceOffering.getHostTag()) && StringUtils.isEmpty(template.getTemplateTag())) {
|
||||
return true;
|
||||
return new HashSet<>();
|
||||
}
|
||||
if (getHostTags() == null) {
|
||||
return false;
|
||||
}
|
||||
HashSet<String> hostTagsSet = new HashSet<>(getHostTags());
|
||||
List<String> tags = new ArrayList<>();
|
||||
List<String> hostTagsList = getHostTags();
|
||||
HashSet<String> hostTagsSet = CollectionUtils.isNotEmpty(hostTagsList) ? new HashSet<>(hostTagsList) : new HashSet<>();
|
||||
HashSet<String> tags = new HashSet<>();
|
||||
if (StringUtils.isNotEmpty(serviceOffering.getHostTag())) {
|
||||
tags.addAll(Arrays.asList(serviceOffering.getHostTag().split(",")));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(template.getTemplateTag()) && !tags.contains(template.getTemplateTag())) {
|
||||
if (StringUtils.isNotEmpty(template.getTemplateTag())) {
|
||||
tags.add(template.getTemplateTag());
|
||||
}
|
||||
tags.removeIf(tag -> !strictHostTags.contains(tag));
|
||||
tags.removeAll(hostTagsSet);
|
||||
return tags;
|
||||
}
|
||||
|
||||
public boolean checkHostServiceOfferingAndTemplateTags(ServiceOffering serviceOffering, VirtualMachineTemplate template, Set<String> strictHostTags) {
|
||||
if (serviceOffering == null || template == null) {
|
||||
return false;
|
||||
}
|
||||
Set<String> tags = getHostServiceOfferingAndTemplateStrictTags(serviceOffering, template, strictHostTags);
|
||||
if (tags.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
List<String> hostTagsList = getHostTags();
|
||||
HashSet<String> hostTagsSet = CollectionUtils.isNotEmpty(hostTagsList) ? new HashSet<>(hostTagsList) : new HashSet<>();
|
||||
return hostTagsSet.containsAll(tags);
|
||||
}
|
||||
|
||||
public Set<String> getHostServiceOfferingAndTemplateMissingTags(ServiceOffering serviceOffering, VirtualMachineTemplate template, Set<String> strictHostTags) {
|
||||
Set<String> tags = getHostServiceOfferingAndTemplateStrictTags(serviceOffering, template, strictHostTags);
|
||||
if (tags.isEmpty()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
List<String> hostTagsList = getHostTags();
|
||||
HashSet<String> hostTagsSet = CollectionUtils.isNotEmpty(hostTagsList) ? new HashSet<>(hostTagsList) : new HashSet<>();
|
||||
tags.removeAll(hostTagsSet);
|
||||
return tags;
|
||||
}
|
||||
|
||||
public boolean checkHostServiceOfferingTags(ServiceOffering serviceOffering) {
|
||||
if (serviceOffering == null) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1309,7 +1309,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
}
|
||||
pstmt.close();
|
||||
if(result.isEmpty()){
|
||||
throw new CloudRuntimeException("No suitable host found for follow compute offering tags: " + computeOfferingTags);
|
||||
throw new CloudRuntimeException("No suitable host found for the following compute offering tags: " + computeOfferingTags);
|
||||
}
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
|
|
@ -1336,7 +1336,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
}
|
||||
pstmt.close();
|
||||
if(result.isEmpty()){
|
||||
throw new CloudRuntimeException("No suitable host found for follow compute offering tags: " + computeOfferingTags);
|
||||
throw new CloudRuntimeException("No suitable host found for the following compute offering tags: " + computeOfferingTags);
|
||||
}
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||
import com.cloud.host.HostTagVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
|
||||
public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
|
||||
|
||||
void persist(long hostId, List<String> hostTags);
|
||||
|
|
@ -31,4 +33,11 @@ public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
|
|||
|
||||
void deleteTags(long hostId);
|
||||
|
||||
boolean updateImplicitTags(long hostId, List<String> hostTags);
|
||||
|
||||
List<HostTagVO> getExplicitHostTags(long hostId);
|
||||
|
||||
HostTagResponse newHostTagResponse(HostTagVO hostTag);
|
||||
|
||||
List<HostTagVO> searchByIds(Long... hostTagIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ package com.cloud.host.dao;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.HostTagVO;
|
||||
|
|
@ -30,14 +32,23 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Component
|
||||
public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements HostTagsDao {
|
||||
protected final SearchBuilder<HostTagVO> HostSearch;
|
||||
protected final GenericSearchBuilder<HostTagVO, String> DistinctImplictTagsSearch;
|
||||
private final SearchBuilder<HostTagVO> stSearch;
|
||||
private final SearchBuilder<HostTagVO> tagIdsearch;
|
||||
private final SearchBuilder<HostTagVO> ImplicitTagsSearch;
|
||||
|
||||
@Inject
|
||||
private ConfigurationDao _configDao;
|
||||
|
||||
public HostTagsDaoImpl() {
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.and("isImplicit", HostSearch.entity().getIsImplicit(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
DistinctImplictTagsSearch = createSearchBuilder(String.class);
|
||||
|
|
@ -45,6 +56,19 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
DistinctImplictTagsSearch.and("hostIds", DistinctImplictTagsSearch.entity().getHostId(), SearchCriteria.Op.IN);
|
||||
DistinctImplictTagsSearch.and("implicitTags", DistinctImplictTagsSearch.entity().getTag(), SearchCriteria.Op.IN);
|
||||
DistinctImplictTagsSearch.done();
|
||||
|
||||
stSearch = createSearchBuilder();
|
||||
stSearch.and("idIN", stSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
stSearch.done();
|
||||
|
||||
tagIdsearch = createSearchBuilder();
|
||||
tagIdsearch.and("id", tagIdsearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
tagIdsearch.done();
|
||||
|
||||
ImplicitTagsSearch = createSearchBuilder();
|
||||
ImplicitTagsSearch.and("hostId", ImplicitTagsSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
ImplicitTagsSearch.and("isImplicit", ImplicitTagsSearch.entity().getIsImplicit(), SearchCriteria.Op.EQ);
|
||||
ImplicitTagsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -79,6 +103,36 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateImplicitTags(long hostId, List<String> hostTags) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.start();
|
||||
SearchCriteria<HostTagVO> sc = ImplicitTagsSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", true);
|
||||
boolean expunged = expunge(sc) > 0;
|
||||
boolean persisted = false;
|
||||
for (String tag : hostTags) {
|
||||
if (StringUtils.isNotBlank(tag)) {
|
||||
HostTagVO vo = new HostTagVO(hostId, tag.trim());
|
||||
vo.setIsImplicit(true);
|
||||
persist(vo);
|
||||
persisted = true;
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
return expunged || persisted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostTagVO> getExplicitHostTags(long hostId) {
|
||||
SearchCriteria<HostTagVO> sc = ImplicitTagsSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", false);
|
||||
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long hostId, List<String> hostTags) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
|
|
@ -86,6 +140,7 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
txn.start();
|
||||
SearchCriteria<HostTagVO> sc = HostSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", false);
|
||||
expunge(sc);
|
||||
|
||||
for (String tag : hostTags) {
|
||||
|
|
@ -97,4 +152,71 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostTagResponse newHostTagResponse(HostTagVO tag) {
|
||||
HostTagResponse tagResponse = new HostTagResponse();
|
||||
|
||||
tagResponse.setName(tag.getTag());
|
||||
tagResponse.setHostId(tag.getHostId());
|
||||
|
||||
tagResponse.setObjectName("hosttag");
|
||||
|
||||
return tagResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostTagVO> searchByIds(Long... tagIds) {
|
||||
String batchCfg = _configDao.getValue("detail.batch.query.size");
|
||||
|
||||
final int detailsBatchSize = batchCfg != null ? Integer.parseInt(batchCfg) : 2000;
|
||||
|
||||
// query details by batches
|
||||
List<HostTagVO> tagList = new ArrayList<>();
|
||||
int curr_index = 0;
|
||||
|
||||
if (tagIds.length > detailsBatchSize) {
|
||||
while ((curr_index + detailsBatchSize) <= tagIds.length) {
|
||||
Long[] ids = new Long[detailsBatchSize];
|
||||
|
||||
for (int k = 0, j = curr_index; j < curr_index + detailsBatchSize; j++, k++) {
|
||||
ids[k] = tagIds[j];
|
||||
}
|
||||
|
||||
SearchCriteria<HostTagVO> sc = stSearch.create();
|
||||
|
||||
sc.setParameters("idIN", (Object[])ids);
|
||||
|
||||
List<HostTagVO> vms = searchIncludingRemoved(sc, null, null, false);
|
||||
|
||||
if (vms != null) {
|
||||
tagList.addAll(vms);
|
||||
}
|
||||
|
||||
curr_index += detailsBatchSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (curr_index < tagIds.length) {
|
||||
int batch_size = (tagIds.length - curr_index);
|
||||
// set the ids value
|
||||
Long[] ids = new Long[batch_size];
|
||||
|
||||
for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
|
||||
ids[k] = tagIds[j];
|
||||
}
|
||||
|
||||
SearchCriteria<HostTagVO> sc = stSearch.create();
|
||||
|
||||
sc.setParameters("idIN", (Object[])ids);
|
||||
|
||||
List<HostTagVO> tags = searchIncludingRemoved(sc, null, null, false);
|
||||
|
||||
if (tags != null) {
|
||||
tagList.addAll(tags);
|
||||
}
|
||||
}
|
||||
|
||||
return tagList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ public interface AutoScaleVmGroupVmMapDao extends GenericDao<AutoScaleVmGroupVmM
|
|||
public boolean removeByVm(long vmId);
|
||||
|
||||
public boolean removeByGroup(long vmGroupId);
|
||||
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ package com.cloud.network.as.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScaleVmGroupVmMapVO;
|
||||
|
|
@ -31,9 +34,6 @@ import com.cloud.vm.VMInstanceVO;
|
|||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Component
|
||||
public class AutoScaleVmGroupVmMapDaoImpl extends GenericDaoBase<AutoScaleVmGroupVmMapVO, Long> implements AutoScaleVmGroupVmMapDao {
|
||||
|
||||
|
|
@ -115,4 +115,16 @@ public class AutoScaleVmGroupVmMapDaoImpl extends GenericDaoBase<AutoScaleVmGrou
|
|||
sc.setParameters("vmGroupId", vmGroupId);
|
||||
return remove(sc) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<AutoScaleVmGroupVmMapVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<AutoScaleVmGroupVmMapVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,5 @@ public interface IPAddressDao extends GenericDao<IPAddressVO, Long> {
|
|||
List<IPAddressVO> listByDcIdAndAssociatedNetwork(long dcId);
|
||||
|
||||
List<IPAddressVO> listByNetworkId(long networkId);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.annotation.PostConstruct;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -534,4 +535,16 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||
sc.setParameters("state", State.Allocated);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<IPAddressVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getAssociatedWithVmId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<IPAddressVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,14 @@
|
|||
// under the License.
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface InlineLoadBalancerNicMapDao extends GenericDao<InlineLoadBalancerNicMapVO, Long> {
|
||||
InlineLoadBalancerNicMapVO findByPublicIpAddress(String publicIpAddress);
|
||||
|
||||
InlineLoadBalancerNicMapVO findByNicId(long nicId);
|
||||
int expungeByNicList(List<Long> nicIds, Long batchSize);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,13 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
|
|
@ -41,4 +45,15 @@ public class InlineLoadBalancerNicMapDaoImpl extends GenericDaoBase<InlineLoadBa
|
|||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByNicList(List<Long> nicIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(nicIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<InlineLoadBalancerNicMapVO> sb = createSearchBuilder();
|
||||
sb.and("nicIds", sb.entity().getNicId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<InlineLoadBalancerNicMapVO> sc = sb.create();
|
||||
sc.setParameters("nicIds", nicIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,4 +42,5 @@ public interface LoadBalancerVMMapDao extends GenericDao<LoadBalancerVMMapVO, Lo
|
|||
LoadBalancerVMMapVO findByLoadBalancerIdAndVmIdVmIp(long loadBalancerId, long instanceId, String instanceIp);
|
||||
|
||||
void remove(long id, long instanceId, String instanceIp, Boolean revoke);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ package com.cloud.network.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
|
||||
|
|
@ -135,4 +136,16 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO
|
|||
sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<LoadBalancerVMMapVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<LoadBalancerVMMapVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,12 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface OpRouterMonitorServiceDao extends GenericDao<OpRouterMonitorServiceVO, Long> {
|
||||
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,27 @@
|
|||
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
public class OpRouterMonitorServiceDaoImpl extends GenericDaoBase<OpRouterMonitorServiceVO, Long> implements OpRouterMonitorServiceDao {
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<OpRouterMonitorServiceVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<OpRouterMonitorServiceVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,5 @@ public interface PortForwardingRulesDao extends GenericDao<PortForwardingRuleVO,
|
|||
PortForwardingRuleVO findByIdAndIp(long id, String secondaryIp);
|
||||
|
||||
List<PortForwardingRuleVO> listByNetworkAndDestIpAddr(String ip4Address, long networkId);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
|
|
@ -170,4 +171,16 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
|
|||
sc.setParameters("dstIp", secondaryIp);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<PortForwardingRuleVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getVirtualMachineId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<PortForwardingRuleVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
package com.cloud.secstorage;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface CommandExecLogDao extends GenericDao<CommandExecLogVO, Long> {
|
||||
public void expungeExpiredRecords(Date cutTime);
|
||||
public Integer getCopyCmdCountForSSVM(Long id);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.cloud.secstorage;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -57,4 +58,16 @@ public class CommandExecLogDaoImpl extends GenericDaoBase<CommandExecLogVO, Long
|
|||
List<CommandExecLogVO> copyCmds = customSearch(sc, null);
|
||||
return copyCmds.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<CommandExecLogVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<CommandExecLogVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,5 @@ public interface SnapshotDao extends GenericDao<SnapshotVO, Long>, StateDao<Snap
|
|||
* @return A list of snapshots filtered by ids.
|
||||
*/
|
||||
List<SnapshotVO> listByIds(Object... ids);
|
||||
List<SnapshotVO> searchByVolumes(List<Long> volumeIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ package com.cloud.storage.dao;
|
|||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -287,4 +289,16 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
|
|||
sc.setParameters("status", (Object[]) status);
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SnapshotVO> searchByVolumes(List<Long> volumeIds) {
|
||||
if (CollectionUtils.isEmpty(volumeIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
SearchBuilder<SnapshotVO> sb = createSearchBuilder();
|
||||
sb.and("volumeIds", sb.entity().getVolumeId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<SnapshotVO> sc = sb.create();
|
||||
sc.setParameters("volumeIds", volumeIds.toArray());
|
||||
return search(sc, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,4 +151,5 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
|
|||
void updateAndRemoveVolume(VolumeVO volume);
|
||||
|
||||
List<VolumeVO> listAllocatedVolumesForAccountDiskOfferingIdsAndNotForVms(long accountId, List<Long> diskOfferingIds, List<Long> vmIds);
|
||||
List<VolumeVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,15 +26,13 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.configuration.Resource;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
import org.apache.cloudstack.reservation.ReservationVO;
|
||||
import org.apache.cloudstack.reservation.dao.ReservationDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Resource;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
|
|
@ -48,12 +46,15 @@ import com.cloud.storage.VolumeVO;
|
|||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.UpdateBuilder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -849,4 +850,18 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||
return volume;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> searchRemovedByVms(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
SearchBuilder<VolumeVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
SearchCriteria<VolumeVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
Filter filter = new Filter(VolumeVO.class, "id", true, 0L, batchSize);
|
||||
return searchIncludingRemoved(sc, filter, null, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -33,6 +36,7 @@ import java.util.List;
|
|||
public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41800to41810.class);
|
||||
private GuestOsMapper guestOsMapper = new GuestOsMapper();
|
||||
private static final int MAX_INDEXED_CHARS_IN_CHAR_SET_UTF8MB4 = 191;
|
||||
|
||||
private SystemVmTemplateRegistration systemVmTemplateRegistration;
|
||||
|
||||
|
|
@ -64,6 +68,7 @@ public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
checkAndUpdateAffinityGroupNameCharSetToUtf8mb4(conn);
|
||||
fixForeignKeyNames(conn);
|
||||
updateGuestOsMappings(conn);
|
||||
copyGuestOsMappingsToVMware80u1();
|
||||
|
|
@ -254,4 +259,32 @@ public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
|
||||
DbUpgradeUtils.addIndexIfNeeded(conn, "vm_stats", "vm_id");
|
||||
}
|
||||
|
||||
private void checkAndUpdateAffinityGroupNameCharSetToUtf8mb4(Connection conn) {
|
||||
LOG.debug("Check and update char set for affinity group name to utf8mb4");
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT MAX(LENGTH(name)) FROM `cloud`.`affinity_group`");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
long maxLengthOfName = rs.getLong(1);
|
||||
if (maxLengthOfName <= MAX_INDEXED_CHARS_IN_CHAR_SET_UTF8MB4) {
|
||||
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`affinity_group` MODIFY `name` VARCHAR(191) CHARACTER SET utf8mb4 NOT NULL");
|
||||
pstmt.executeUpdate();
|
||||
LOG.debug("Successfully updated char set for affinity group name to utf8mb4");
|
||||
} else {
|
||||
LOG.warn("Unable to update char set for affinity group name, as there are some names with more than " + MAX_INDEXED_CHARS_IN_CHAR_SET_UTF8MB4 +
|
||||
" chars (max supported chars for index)");
|
||||
}
|
||||
}
|
||||
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null && !pstmt.isClosed()) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.warn("Exception while updating char set for affinity group name to utf8mb4: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,5 +41,6 @@ public interface ItWorkDao extends GenericDao<ItWorkVO, String> {
|
|||
boolean updateStep(ItWorkVO work, Step step);
|
||||
|
||||
List<ItWorkVO> listWorkInProgressFor(long nodeId);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package com.cloud.vm;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -103,4 +103,16 @@ public class ItWorkDaoImpl extends GenericDaoBase<ItWorkVO, String> implements I
|
|||
return search(sc, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<ItWorkVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<ItWorkVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.cloud.vm.ConsoleSessionVO;
|
|||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ConsoleSessionDao extends GenericDao<ConsoleSessionVO, Long> {
|
||||
|
||||
|
|
@ -33,4 +34,6 @@ public interface ConsoleSessionDao extends GenericDao<ConsoleSessionVO, Long> {
|
|||
int expungeSessionsOlderThanDate(Date date);
|
||||
|
||||
void acquireSession(String sessionUuid);
|
||||
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@
|
|||
|
||||
package com.cloud.vm.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.vm.ConsoleSessionVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ConsoleSessionDaoImpl extends GenericDaoBase<ConsoleSessionVO, Long> implements ConsoleSessionDao {
|
||||
|
||||
|
|
@ -65,5 +68,15 @@ public class ConsoleSessionDaoImpl extends GenericDaoBase<ConsoleSessionVO, Long
|
|||
update(consoleSessionVO.getId(), consoleSessionVO);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<ConsoleSessionVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<ConsoleSessionVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,4 +94,5 @@ public interface NicDao extends GenericDao<NicVO, Long> {
|
|||
NicVO findByIpAddressAndVmType(String ip, VirtualMachine.Type vmType);
|
||||
|
||||
List<NicVO> listByNetworkIdAndType(long networkId, VirtualMachine.Type vmType);
|
||||
List<NicVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@
|
|||
package com.cloud.vm.dao;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.Filter;
|
||||
|
|
@ -398,4 +400,18 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
|
|||
sc.setParameters("vmType", vmType);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicVO> searchRemovedByVms(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
SearchBuilder<NicVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getInstanceId(), SearchCriteria.Op.IN);
|
||||
sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
SearchCriteria<NicVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
Filter filter = new Filter(NicVO.class, "id", true, 0L, batchSize);
|
||||
return searchIncludingRemoved(sc, filter, null, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,5 @@ public interface NicExtraDhcpOptionDao extends GenericDao<NicExtraDhcpOptionVO,
|
|||
* @param extraDhcpOptions
|
||||
*/
|
||||
void saveExtraDhcpOptions(List<NicExtraDhcpOptionVO> extraDhcpOptions);
|
||||
int expungeByNicList(List<Long> nicIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.vm.NicExtraDhcpOption;
|
||||
|
|
@ -74,4 +74,15 @@ public class NicExtraDhcpOptionDaoImpl extends GenericDaoBase<NicExtraDhcpOptio
|
|||
expunge(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByNicList(List<Long> nicIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(nicIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<NicExtraDhcpOptionVO> sb = createSearchBuilder();
|
||||
sb.and("nicIds", sb.entity().getNicId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<NicExtraDhcpOptionVO> sc = sb.create();
|
||||
sc.setParameters("nicIds", nicIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,4 +55,5 @@ public interface NicSecondaryIpDao extends GenericDao<NicSecondaryIpVO, Long> {
|
|||
List<NicSecondaryIpVO> listSecondaryIpUsingKeyword(long nicId, String keyword);
|
||||
|
||||
int moveSecondaryIps(long fromNicId, long toNicId);
|
||||
int expungeByVmList(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.cloud.vm.dao;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -192,4 +193,16 @@ public class NicSecondaryIpDaoImpl extends GenericDaoBase<NicSecondaryIpVO, Long
|
|||
|
||||
return update(update, sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expungeByVmList(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return 0;
|
||||
}
|
||||
SearchBuilder<NicSecondaryIpVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getVmId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<NicSecondaryIpVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return batchExpunge(sc, batchSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,4 +167,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
|||
void updateSystemVmTemplateId(long templateId, Hypervisor.HypervisorType hypervisorType);
|
||||
|
||||
List<VMInstanceVO> listByHostOrLastHostOrHostPod(long hostId, long podId);
|
||||
List<VMInstanceVO> searchRemovedByRemoveDate(final Date startDate, final Date endDate, final Long batchSize,
|
||||
List<Long> skippedVmIds);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -40,6 +41,7 @@ import com.cloud.utils.DateUtil;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.Attribute;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
|
|
@ -1030,4 +1032,26 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
sc.setParameters("podId", String.valueOf(podId));
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> searchRemovedByRemoveDate(Date startDate, Date endDate, Long batchSize,
|
||||
List<Long> skippedVmIds) {
|
||||
SearchBuilder<VMInstanceVO> sb = createSearchBuilder();
|
||||
sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
sb.and("startDate", sb.entity().getRemoved(), SearchCriteria.Op.GTEQ);
|
||||
sb.and("endDate", sb.entity().getRemoved(), SearchCriteria.Op.LTEQ);
|
||||
sb.and("skippedVmIds", sb.entity().getId(), Op.NOTIN);
|
||||
SearchCriteria<VMInstanceVO> sc = sb.create();
|
||||
if (startDate != null) {
|
||||
sc.setParameters("startDate", startDate);
|
||||
}
|
||||
if (endDate != null) {
|
||||
sc.setParameters("endDate", endDate);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(skippedVmIds)) {
|
||||
sc.setParameters("skippedVmIds", skippedVmIds.toArray());
|
||||
}
|
||||
Filter filter = new Filter(VMInstanceVO.class, "id", true, 0L, batchSize);
|
||||
return searchIncludingRemoved(sc, filter, null, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,6 @@ public interface VMSnapshotDao extends GenericDao<VMSnapshotVO, Long>, StateDao<
|
|||
VMSnapshotVO findByName(Long vmId, String name);
|
||||
|
||||
List<VMSnapshotVO> listByAccountId(Long accountId);
|
||||
List<VMSnapshotVO> searchByVms(List<Long> vmIds);
|
||||
List<VMSnapshotVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,15 @@
|
|||
|
||||
package com.cloud.vm.snapshot.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -182,4 +184,29 @@ public class VMSnapshotDaoImpl extends GenericDaoBase<VMSnapshotVO, Long> implem
|
|||
return rows > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMSnapshotVO> searchByVms(List<Long> vmIds) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
SearchBuilder<VMSnapshotVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getVmId(), SearchCriteria.Op.IN);
|
||||
SearchCriteria<VMSnapshotVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMSnapshotVO> searchRemovedByVms(List<Long> vmIds, Long batchSize) {
|
||||
if (CollectionUtils.isEmpty(vmIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
SearchBuilder<VMSnapshotVO> sb = createSearchBuilder();
|
||||
sb.and("vmIds", sb.entity().getVmId(), SearchCriteria.Op.IN);
|
||||
sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
SearchCriteria<VMSnapshotVO> sc = sb.create();
|
||||
sc.setParameters("vmIds", vmIds.toArray());
|
||||
Filter filter = new Filter(VMSnapshotVO.class, "id", true, 0L, batchSize);
|
||||
return searchIncludingRemoved(sc, filter, null, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,14 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.user.ResourceReservation;
|
||||
|
||||
import com.cloud.configuration.Resource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "resource_reservation")
|
||||
|
|
@ -57,6 +61,12 @@ public class ReservationVO implements ResourceReservation {
|
|||
@Column(name = "amount")
|
||||
long amount;
|
||||
|
||||
@Column(name = "mgmt_server_id")
|
||||
Long managementServerId;
|
||||
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
protected ReservationVO() {
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +79,7 @@ public class ReservationVO implements ResourceReservation {
|
|||
this.resourceType = resourceType;
|
||||
this.tag = tag;
|
||||
this.amount = delta;
|
||||
this.managementServerId = ManagementServerNode.getManagementServerId();
|
||||
}
|
||||
|
||||
public ReservationVO(Long accountId, Long domainId, Resource.ResourceType resourceType, Long delta) {
|
||||
|
|
@ -114,4 +125,16 @@ public class ReservationVO implements ResourceReservation {
|
|||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Long getManagementServerId() {
|
||||
return managementServerId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue