mirror of https://github.com/apache/cloudstack.git
Merge branch 'main' of https://github.com/apache/cloudstack into nsx-integration
This commit is contained in:
commit
d8998d0833
|
|
@ -27,25 +27,6 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
permissions:
|
||||
contents: read # for actions/checkout to fetch code
|
||||
statuses: write # for github/super-linter to mark status of each linter run
|
||||
name: Super-Linter Check
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
- name: SuperLinter
|
||||
uses: github/super-linter/slim@v4.9.6
|
||||
env:
|
||||
DEFAULT_BRANCH: main
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_PYTHON_FLAKE8: true
|
||||
pre-commit:
|
||||
name: Run pre-commit
|
||||
runs-on: ubuntu-22.04
|
||||
|
|
|
|||
|
|
@ -34,10 +34,39 @@ repos:
|
|||
#- id: check-merge-conflict
|
||||
- id: check-vcs-permalinks
|
||||
#- id: check-yaml
|
||||
#- id: detect-private-key
|
||||
- id: detect-private-key
|
||||
exclude: >
|
||||
(?x)
|
||||
^scripts/vm/systemvm/id_rsa\.cloud$|
|
||||
^server/src/test/java/com/cloud/keystore/KeystoreTest\.java$|
|
||||
^server/src/test/resources/certs/dsa_self_signed\.key$|
|
||||
^server/src/test/resources/certs/non_root\.key$|
|
||||
^server/src/test/resources/certs/root_chain\.key$|
|
||||
^server/src/test/resources/certs/rsa_ca_signed\.key$|
|
||||
^server/src/test/resources/certs/rsa_self_signed_with_pwd\.key$|
|
||||
^server/src/test/resources/certs/rsa_self_signed\.key$|
|
||||
^services/console-proxy/rdpconsole/src/test/doc/rdp-key\.pem$|
|
||||
^systemvm/agent/certs/localhost\.key$|
|
||||
^systemvm/agent/certs/realhostip\.key$
|
||||
- id: end-of-file-fixer
|
||||
exclude: \.vhd$
|
||||
#- id: fix-byte-order-marker
|
||||
- id: mixed-line-ending
|
||||
files: \.(java|md|py|txt|yaml|yml)$
|
||||
# - id: trailing-whitespace
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 6.1.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
args: [--config, .github/linters/.flake8]
|
||||
exclude: >
|
||||
(?x)
|
||||
^agent/bindir/cloud-setup-agent\.in$|
|
||||
^client/bindir/cloud-update-xenserver-licenses\.in$|
|
||||
^cloud-cli/bindir/cloud-tool$|
|
||||
^python/bindir/cloud-grab-dependent-library-versions$|
|
||||
^python/bindir/cloud-setup-baremetal$|
|
||||
^scripts/vm/hypervisor/xenserver/storagePlugin$|
|
||||
^scripts/vm/hypervisor/xenserver/vmopspremium$|
|
||||
^setup/bindir/cloud-setup-encryption\.in$|
|
||||
^venv/.*$
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Apache CloudStack [](https://github.com/apache/cloudstack/actions/workflows/build.yml) [](https://github.com/apache/cloudstack/actions/workflows/ui.yml) [](https://github.com/apache/cloudstack/actions/workflows/rat.yml) [](https://github.com/apache/cloudstack/actions/workflows/ci.yml) [](https://sonarcloud.io/dashboard?id=apache_cloudstack) [](https://codecov.io/gh/apache/cloudstack)
|
||||
|
||||

|
||||
[](https://cloudstack.apache.org/)
|
||||
|
||||
Apache CloudStack is open source software designed to deploy and manage large
|
||||
networks of virtual machines, as a highly available, highly scalable
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class Hypervisor {
|
|||
static Map<String, HypervisorType> hypervisorTypeMap;
|
||||
static Map<HypervisorType, ImageFormat> supportedImageFormatMap;
|
||||
|
||||
public static enum HypervisorType {
|
||||
public enum HypervisorType {
|
||||
None, //for storage hosts
|
||||
XenServer,
|
||||
KVM,
|
||||
|
|
@ -40,6 +40,7 @@ public class Hypervisor {
|
|||
Ovm,
|
||||
Ovm3,
|
||||
LXC,
|
||||
Custom,
|
||||
|
||||
Any; /*If you don't care about the hypervisor type*/
|
||||
|
||||
|
|
@ -57,6 +58,7 @@ public class Hypervisor {
|
|||
hypervisorTypeMap.put("lxc", HypervisorType.LXC);
|
||||
hypervisorTypeMap.put("any", HypervisorType.Any);
|
||||
hypervisorTypeMap.put("ovm3", HypervisorType.Ovm3);
|
||||
hypervisorTypeMap.put("custom", HypervisorType.Custom);
|
||||
|
||||
supportedImageFormatMap = new HashMap<>();
|
||||
supportedImageFormatMap.put(HypervisorType.XenServer, ImageFormat.VHD);
|
||||
|
|
@ -68,7 +70,19 @@ public class Hypervisor {
|
|||
|
||||
public static HypervisorType getType(String hypervisor) {
|
||||
return hypervisor == null ? HypervisorType.None :
|
||||
hypervisorTypeMap.getOrDefault(hypervisor.toLowerCase(Locale.ROOT), HypervisorType.None);
|
||||
(hypervisor.toLowerCase(Locale.ROOT).equalsIgnoreCase(
|
||||
HypervisorGuru.HypervisorCustomDisplayName.value()) ? Custom :
|
||||
hypervisorTypeMap.getOrDefault(hypervisor.toLowerCase(Locale.ROOT), HypervisorType.None));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of a hypervisor type in case the custom hypervisor is used,
|
||||
* using the 'hypervisor.custom.display.name' setting. Otherwise, returns hypervisor name
|
||||
*/
|
||||
public String getHypervisorDisplayName() {
|
||||
return !Hypervisor.HypervisorType.Custom.equals(this) ?
|
||||
this.toString() :
|
||||
HypervisorGuru.HypervisorCustomDisplayName.value();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.backup.Backup;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
|
|
@ -35,6 +36,10 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
|
||||
public interface HypervisorGuru extends Adapter {
|
||||
|
||||
ConfigKey<String> HypervisorCustomDisplayName = new ConfigKey<>(String.class,
|
||||
"hypervisor.custom.display.name", ConfigKey.CATEGORY_ADVANCED, "Custom",
|
||||
"Display name for custom hypervisor", true, ConfigKey.Scope.Global, null);
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity,
|
|||
|
||||
String getUserData();
|
||||
|
||||
Long getUserDataId();
|
||||
|
||||
String getUserDataDetails();
|
||||
|
||||
public String getUuid();
|
||||
|
||||
public Long getZoneId();
|
||||
|
|
|
|||
|
|
@ -34,4 +34,6 @@ public interface GuestOS extends InternalIdentity, Identity {
|
|||
Date getRemoved();
|
||||
|
||||
boolean getIsUserDefined();
|
||||
|
||||
boolean getForDisplay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ import java.lang.reflect.Field;
|
|||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -42,6 +44,7 @@ import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
|||
import org.apache.cloudstack.query.QueryService;
|
||||
import org.apache.cloudstack.storage.ImageStoreService;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.ConfigurationService;
|
||||
|
|
@ -456,4 +459,18 @@ public abstract class BaseCmd {
|
|||
return ApiCommandResourceType.None;
|
||||
}
|
||||
|
||||
public Map<String, String> convertDetailsToMap(Map details) {
|
||||
Map<String, String> detailsMap = new HashMap<String, String>();
|
||||
if (MapUtils.isNotEmpty(details)) {
|
||||
Collection parameterCollection = details.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (Map.Entry<String,String> entry: value.entrySet()) {
|
||||
detailsMap.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return detailsMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -61,6 +62,8 @@ public class AddGuestOsCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = false, description = "Map of (key/value pairs)")
|
||||
private Map details;
|
||||
|
||||
@Parameter(name="forDisplay", type=CommandType.BOOLEAN, description="whether this guest OS is available for end users", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -79,7 +82,7 @@ public class AddGuestOsCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
public Map getDetails() {
|
||||
Map<String, String> detailsMap = new HashMap<String, String>();
|
||||
Map<String, String> detailsMap = new HashMap<>();
|
||||
if (!MapUtils.isEmpty(details)) {
|
||||
Collection<?> servicesCollection = details.values();
|
||||
Iterator<?> iter = servicesCollection.iterator();
|
||||
|
|
@ -93,6 +96,9 @@ public class AddGuestOsCmd extends BaseAsyncCreateCmd {
|
|||
return detailsMap;
|
||||
}
|
||||
|
||||
public Boolean getForDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.storage.GuestOS;
|
||||
|
|
@ -57,8 +58,10 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = false, description = "Map of (key/value pairs)")
|
||||
private Map details;
|
||||
|
||||
@Parameter(name="forDisplay", type=CommandType.BOOLEAN, description="whether this guest OS is available for end users", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
|
@ -71,7 +74,7 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
public Map getDetails() {
|
||||
Map<String, String> detailsMap = new HashMap<String, String>();;
|
||||
Map<String, String> detailsMap = new HashMap<>();;
|
||||
if (MapUtils.isNotEmpty(detailsMap)) {
|
||||
Collection<?> servicesCollection = details.values();
|
||||
Iterator<?> iter = servicesCollection.iterator();
|
||||
|
|
@ -85,6 +88,10 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
|
|||
return detailsMap;
|
||||
}
|
||||
|
||||
public Boolean getForDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the internal lb vm")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.")
|
||||
private Boolean forced;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the router")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.")
|
||||
private Boolean forced;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
|
|||
description = "The ID of the system virtual machine")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.")
|
||||
private Boolean forced;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
|
|||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UserDataResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
|
@ -107,6 +108,12 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
since = "4.18.0")
|
||||
private String userData;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, description = "the ID of the Userdata", since = "4.18.1")
|
||||
private Long userDataId;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA_DETAILS, type = CommandType.MAP, description = "used to specify the parameters values for the variables in userdata.", since = "4.18.1")
|
||||
private Map userDataDetails;
|
||||
|
||||
@Parameter(name = ApiConstants.AUTOSCALE_USER_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = UserResponse.class,
|
||||
|
|
@ -163,6 +170,14 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
return userData;
|
||||
}
|
||||
|
||||
public Long getUserDataId() {
|
||||
return userDataId;
|
||||
}
|
||||
|
||||
public Map<String, String> getUserDataDetails() {
|
||||
return convertDetailsToMap(userDataDetails);
|
||||
}
|
||||
|
||||
public Long getAutoscaleUserId() {
|
||||
return autoscaleUserId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.apache.cloudstack.api.ServerApiException;
|
|||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UserDataResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
|
|
@ -102,6 +103,14 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd {
|
|||
since = "4.18.0")
|
||||
private String userData;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, description = "the ID of the userdata",
|
||||
since = "4.18.1")
|
||||
private Long userDataId;
|
||||
|
||||
@Parameter(name = ApiConstants.USER_DATA_DETAILS, type = CommandType.MAP, description = "used to specify the parameters values for the variables in userdata.",
|
||||
since = "4.18.1")
|
||||
private Map userDataDetails;
|
||||
|
||||
@Parameter(name = ApiConstants.AUTOSCALE_USER_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = UserResponse.class,
|
||||
|
|
@ -156,6 +165,14 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd {
|
|||
return userData;
|
||||
}
|
||||
|
||||
public Long getUserDataId() {
|
||||
return userDataId;
|
||||
}
|
||||
|
||||
public Map<String, String> getUserDataDetails() {
|
||||
return convertDetailsToMap(userDataDetails);
|
||||
}
|
||||
|
||||
public Long getAutoscaleUserId() {
|
||||
return autoscaleUserId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ package org.apache.cloudstack.api.command.user.guest;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
|
|
@ -51,6 +53,10 @@ public class ListGuestOsCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "list os by description", since = "3.0.1")
|
||||
private String description;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter",
|
||||
since = "4.18.1", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -67,6 +73,10 @@ public class ListGuestOsCmd extends BaseListCmd {
|
|||
return description;
|
||||
}
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return BooleanUtils.toBooleanDefaultIfNull(display, true);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -74,8 +84,8 @@ public class ListGuestOsCmd extends BaseListCmd {
|
|||
@Override
|
||||
public void execute() {
|
||||
Pair<List<? extends GuestOS>, Integer> result = _mgr.listGuestOSByCriteria(this);
|
||||
ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
|
||||
List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
|
||||
ListResponse<GuestOSResponse> response = new ListResponse<>();
|
||||
List<GuestOSResponse> osResponses = new ArrayList<>();
|
||||
for (GuestOS guestOS : result.first()) {
|
||||
GuestOSResponse guestOSResponse = _responseGenerator.createGuestOSResponse(guestOS);
|
||||
osResponses.add(guestOSResponse);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,9 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
|
|||
private Long projectId;
|
||||
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning a network. " +
|
||||
"If no account is provided then network will be assigned to the caller account and domain")
|
||||
"If the account is not specified, but the acltype is Account or not specified, the network will be automatically assigned to the caller account and domain. " +
|
||||
"To create a network under the domain without linking it to any account, make sure to include acltype=Domain parameter in the api call. " +
|
||||
"If account is not specified, but acltype is Domain, the network will be created for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.SUBDOMAIN_ACCESS,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = DomainResponse.class,
|
||||
description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.")
|
||||
description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume. If account is NOT provided then snapshot will be assigned to the caller account and domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "The ID of the disk volume")
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -342,9 +343,11 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
|
||||
"Parameter zoneids cannot combine all zones (-1) option with other zones");
|
||||
|
||||
if (isDirectDownload() && !getHypervisor().equalsIgnoreCase(Hypervisor.HypervisorType.KVM.toString())) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
|
||||
"Parameter directdownload is only allowed for KVM templates");
|
||||
String customHypervisor = HypervisorGuru.HypervisorCustomDisplayName.value();
|
||||
if (isDirectDownload() && !(getHypervisor().equalsIgnoreCase(Hypervisor.HypervisorType.KVM.toString())
|
||||
|| getHypervisor().equalsIgnoreCase(customHypervisor))) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Parameter directdownload " +
|
||||
"is only allowed for KVM or %s templates", customHypervisor));
|
||||
}
|
||||
|
||||
if (!isDeployAsIs() && osTypeId == null) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the virtual machine. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.")
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used. If account is NOT provided then virtual machine will be assigned to the caller account and domain.")
|
||||
private Long domainId;
|
||||
|
||||
//Network information
|
||||
|
|
@ -317,17 +317,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
Map<String, String> customparameterMap = new HashMap<String, String>();
|
||||
if (details != null && details.size() != 0) {
|
||||
Collection parameterCollection = details.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (Map.Entry<String,String> entry: value.entrySet()) {
|
||||
customparameterMap.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> customparameterMap = convertDetailsToMap(details);
|
||||
|
||||
if (getBootType() != null) {
|
||||
customparameterMap.put(getBootType().toString(), getBootMode().toString());
|
||||
}
|
||||
|
|
@ -466,18 +457,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||
}
|
||||
|
||||
public Map<String, String> getUserdataDetails() {
|
||||
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
|
||||
if (userdataDetails != null && userdataDetails.size() != 0) {
|
||||
Collection parameterCollection = userdataDetails.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (Map.Entry<String,String> entry: value.entrySet()) {
|
||||
userdataDetailsMap.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return userdataDetailsMap;
|
||||
return convertDetailsToMap(userdataDetails);
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
|||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@APICommand(name = "resetUserDataForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the UserData for virtual machine. " +
|
||||
|
|
@ -117,18 +114,7 @@ public class ResetVMUserDataCmd extends BaseCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public Map<String, String> getUserdataDetails() {
|
||||
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
|
||||
if (userdataDetails != null && userdataDetails.size() != 0) {
|
||||
Collection parameterCollection = userdataDetails.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (Map.Entry<String,String> entry: value.entrySet()) {
|
||||
userdataDetailsMap.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return userdataDetailsMap;
|
||||
return convertDetailsToMap(userdataDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vm;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -99,17 +96,7 @@ public class ScaleVMCmd extends BaseAsyncCmd implements UserCmd {
|
|||
//it is because details.values() cannot be cast to a map.
|
||||
//it gives a exception
|
||||
public Map<String, String> getDetails() {
|
||||
Map<String, String> customparameterMap = new HashMap<String, String>();
|
||||
if (details != null && details.size() != 0) {
|
||||
Collection parameterCollection = details.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (String key : value.keySet()) {
|
||||
customparameterMap.put(key, value.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> customparameterMap = convertDetailsToMap(details);
|
||||
|
||||
if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk()));
|
||||
if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate()));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ public class StopVMCmd extends BaseAsyncCmd implements UserCmd {
|
|||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM "
|
||||
+ "(vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). The caller knows the VM is stopped.")
|
||||
+ "(vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted)."
|
||||
+ " This option is to be used if the caller knows the VM is stopped and should be marked as such.")
|
||||
private Boolean forced;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.apache.cloudstack.api.command.user.vm;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -176,18 +175,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction,
|
|||
}
|
||||
|
||||
public Map<String, String> getUserdataDetails() {
|
||||
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
|
||||
if (userdataDetails != null && userdataDetails.size() != 0) {
|
||||
Collection parameterCollection = userdataDetails.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (Map.Entry<String,String> entry: value.entrySet()) {
|
||||
userdataDetailsMap.put(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return userdataDetailsMap;
|
||||
return convertDetailsToMap(userdataDetails);
|
||||
}
|
||||
|
||||
public Boolean getDisplayVm() {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vm;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -95,17 +92,7 @@ public class UpgradeVMCmd extends BaseCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
Map<String, String> customparameterMap = new HashMap<String, String>();
|
||||
if (details != null && details.size() != 0) {
|
||||
Collection parameterCollection = details.values();
|
||||
Iterator iter = parameterCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> value = (HashMap<String, String>)iter.next();
|
||||
for (String key : value.keySet()) {
|
||||
customparameterMap.put(key, value.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> customparameterMap = convertDetailsToMap(details);
|
||||
|
||||
if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk()));
|
||||
if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate()));
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd implements UserC
|
|||
type = CommandType.UUID,
|
||||
entityType = DomainResponse.class,
|
||||
description = "the domain ID associated with the disk offering. If used with the account parameter"
|
||||
+ " returns the disk volume associated with the account for the specified domain.")
|
||||
+ " returns the disk volume associated with the account for the specified domain." +
|
||||
"If account is NOT provided then the volume will be assigned to the caller account and domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.DISK_OFFERING_ID,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd implements UserCmd {
|
|||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = DomainResponse.class,
|
||||
description = "an optional domainId. If the account parameter is used, domainId must also be used.")
|
||||
description = "an optional domainId. If the account parameter is used, domainId must also be used. If account is NOT provided then volume will be assigned to the caller account and domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional accountName. Must be used with domainId.")
|
||||
|
|
|
|||
|
|
@ -72,6 +72,18 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
@Param(description = "Base 64 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")
|
||||
private String userDataId;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA_NAME) @Param(description="the name of userdata used for the VM", since = "4.18.1")
|
||||
private String userDataName;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA_POLICY) @Param(description="the userdata override policy with the userdata provided while deploying VM", since = "4.18.1")
|
||||
private String userDataPolicy;
|
||||
|
||||
@SerializedName(ApiConstants.USER_DATA_DETAILS) @Param(description="list of variables and values for the variables declared in userdata", since = "4.18.1")
|
||||
private String userDataDetails;
|
||||
|
||||
@SerializedName(ApiConstants.AUTOSCALE_USER_ID)
|
||||
@Param(description = "the ID of the user used to launch and destroy the VMs")
|
||||
private String autoscaleUserId;
|
||||
|
|
@ -153,6 +165,22 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
this.userData = userData;
|
||||
}
|
||||
|
||||
public void setUserDataId(String userDataId) {
|
||||
this.userDataId = userDataId;
|
||||
}
|
||||
|
||||
public void setUserDataName(String userDataName) {
|
||||
this.userDataName = userDataName;
|
||||
}
|
||||
|
||||
public void setUserDataPolicy(String userDataPolicy) {
|
||||
this.userDataPolicy = userDataPolicy;
|
||||
}
|
||||
|
||||
public void setUserDataDetails(String userDataDetails) {
|
||||
this.userDataDetails = userDataDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
|
|
@ -193,4 +221,24 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
|
||||
public String getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
public String getUserDataId() {
|
||||
return userDataId;
|
||||
}
|
||||
|
||||
public String getUserDataName() {
|
||||
return userDataName;
|
||||
}
|
||||
|
||||
public String getUserDataPolicy() {
|
||||
return userDataPolicy;
|
||||
}
|
||||
|
||||
public String getUserDataDetails() {
|
||||
return userDataDetails;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import org.apache.cloudstack.backup.Backup;
|
|||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EntityReference(value = Backup.class)
|
||||
public class BackupResponse extends BaseResponse {
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ public class BackupResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.CREATED)
|
||||
@Param(description = "backup date")
|
||||
private String date;
|
||||
private Date date;
|
||||
|
||||
@SerializedName(ApiConstants.SIZE)
|
||||
@Param(description = "backup size in bytes")
|
||||
|
|
@ -140,11 +142,11 @@ public class BackupResponse extends BaseResponse {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import org.apache.cloudstack.backup.Backup;
|
|||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EntityReference(value = Backup.RestorePoint.class)
|
||||
public class BackupRestorePointResponse extends BaseResponse {
|
||||
|
||||
|
|
@ -34,7 +36,7 @@ public class BackupRestorePointResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.CREATED)
|
||||
@Param(description = "created time")
|
||||
private String created;
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.TYPE)
|
||||
@Param(description = "restore point type")
|
||||
|
|
@ -48,11 +50,11 @@ public class BackupRestorePointResponse extends BaseResponse {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
public Date getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ public class GuestOSResponse extends BaseResponse {
|
|||
@Param(description = "is the guest OS user defined")
|
||||
private String isUserDefined;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "is the guest OS visible for the users")
|
||||
private Boolean forDisplay;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -103,4 +107,12 @@ public class GuestOSResponse extends BaseResponse {
|
|||
this.isUserDefined = isUserDefined;
|
||||
}
|
||||
|
||||
public Boolean getForDisplay() {
|
||||
return this.forDisplay;
|
||||
}
|
||||
|
||||
public void setForDisplay(final Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.apache.cloudstack.api.EntityReference;
|
|||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.HYPERVISOR)
|
||||
@Param(description = "the host hypervisor")
|
||||
private HypervisorType hypervisor;
|
||||
private String hypervisor;
|
||||
|
||||
@SerializedName("cpunumber")
|
||||
@Param(description = "the CPU number of the host")
|
||||
|
|
@ -295,7 +294,7 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public void setHypervisor(HypervisorType hypervisor) {
|
||||
public void setHypervisor(String hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
|
|||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
|
@ -89,7 +88,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
|
||||
@SerializedName(ApiConstants.HYPERVISOR)
|
||||
@Param(description = "the host hypervisor")
|
||||
private HypervisorType hypervisor;
|
||||
private String hypervisor;
|
||||
|
||||
@SerializedName("cpusockets")
|
||||
@Param(description = "the number of CPU sockets on the host")
|
||||
|
|
@ -335,7 +334,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public void setHypervisor(HypervisorType hypervisor) {
|
||||
public void setHypervisor(String hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +601,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
return version;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisor() {
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import org.apache.cloudstack.api.ApiConstants;
|
|||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -37,7 +36,7 @@ public class HypervisorCapabilitiesResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.HYPERVISOR)
|
||||
@Param(description = "the hypervisor type")
|
||||
private HypervisorType hypervisor;
|
||||
private String hypervisor;
|
||||
|
||||
@SerializedName(ApiConstants.MAX_GUESTS_LIMIT)
|
||||
@Param(description = "the maximum number of guest vms recommended for this hypervisor")
|
||||
|
|
@ -83,11 +82,11 @@ public class HypervisorCapabilitiesResponse extends BaseResponse {
|
|||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisor() {
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
public void setHypervisor(HypervisorType hypervisor) {
|
||||
public void setHypervisor(String hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
|
|||
private String group;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the ID of the availablility zone for the virtual machine")
|
||||
@Param(description = "the ID of the availability zone for the virtual machine")
|
||||
private String zoneId;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_NAME)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.apache.cloudstack.api.ApiConstants;
|
|||
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -111,7 +110,7 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
|
|||
|
||||
@SerializedName(ApiConstants.HYPERVISOR)
|
||||
@Param(description = "the type of hypervisor on which snapshot is stored")
|
||||
private Hypervisor.HypervisorType hypervisor;
|
||||
private String hypervisor;
|
||||
|
||||
public VMSnapshotResponse() {
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
|
|
@ -266,11 +265,11 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
|
|||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Hypervisor.HypervisorType getHypervisor() {
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
public void setHypervisor(Hypervisor.HypervisorType hypervisor) {
|
||||
public void setHypervisor(String hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.apache.cloudstack.backup;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
|
@ -58,10 +60,10 @@ public interface Backup extends ControlledEntity, InternalIdentity, Identity {
|
|||
|
||||
class RestorePoint {
|
||||
private String id;
|
||||
private String created;
|
||||
private Date created;
|
||||
private String type;
|
||||
|
||||
public RestorePoint(String id, String created, String type) {
|
||||
public RestorePoint(String id, Date created, String type) {
|
||||
this.id = id;
|
||||
this.created = created;
|
||||
this.type = type;
|
||||
|
|
@ -75,11 +77,11 @@ public interface Backup extends ControlledEntity, InternalIdentity, Identity {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
public Date getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +136,7 @@ public interface Backup extends ControlledEntity, InternalIdentity, Identity {
|
|||
long getVmId();
|
||||
String getExternalId();
|
||||
String getType();
|
||||
String getDate();
|
||||
Date getDate();
|
||||
Backup.Status getStatus();
|
||||
Long getSize();
|
||||
Long getProtectedSize();
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ import com.cloud.storage.Storage;
|
|||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.StorageUtil;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.Volume;
|
||||
|
|
@ -131,6 +132,7 @@ import com.cloud.storage.VolumeApiService;
|
|||
import com.cloud.storage.VolumeDetailVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateDetailsDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeDetailsDao;
|
||||
|
|
@ -243,6 +245,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
VolumeApiService _volumeApiService;
|
||||
@Inject
|
||||
PassphraseDao passphraseDao;
|
||||
@Inject
|
||||
StoragePoolHostDao storagePoolHostDao;
|
||||
|
||||
@Inject
|
||||
protected SnapshotHelper snapshotHelper;
|
||||
|
|
@ -656,7 +660,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
}
|
||||
|
||||
@DB
|
||||
public VolumeInfo createVolume(VolumeInfo volumeInfo, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId, ServiceOffering offering, DiskOffering diskOffering,
|
||||
public VolumeInfo createVolume(VolumeInfo volumeInfo, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId,
|
||||
Long hostId, ServiceOffering offering, DiskOffering diskOffering,
|
||||
List<StoragePool> avoids, long size, HypervisorType hyperType) {
|
||||
// update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage)
|
||||
volumeInfo = volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volumeInfo.getId(), hyperType);
|
||||
|
|
@ -691,7 +696,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
|
||||
final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(avoids);
|
||||
|
||||
pool = findStoragePool(dskCh, dc, pod, clusterId, vm.getHostId(), vm, avoidPools);
|
||||
pool = findStoragePool(dskCh, dc, pod, clusterId, hostId, vm, avoidPools);
|
||||
if (pool == null) {
|
||||
String msg = String.format("Unable to find suitable primary storage when creating volume [%s].", volumeToString);
|
||||
s_logger.error(msg);
|
||||
|
|
@ -1122,10 +1127,17 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace(String.format("storage-pool %s/%s is associated with cluster %d",storagePool.getName(), storagePool.getUuid(), clusterId));
|
||||
}
|
||||
Long hostId = vm.getHostId();
|
||||
if (hostId == null && storagePool.isLocal()) {
|
||||
List<StoragePoolHostVO> poolHosts = storagePoolHostDao.listByPoolId(storagePool.getId());
|
||||
if (poolHosts.size() > 0) {
|
||||
hostId = poolHosts.get(0).getHostId();
|
||||
}
|
||||
}
|
||||
|
||||
VolumeInfo vol = null;
|
||||
if (volumeInfo.getState() == Volume.State.Allocated) {
|
||||
vol = createVolume(volumeInfo, vm, rootDiskTmplt, dcVO, pod, clusterId, svo, diskVO, new ArrayList<StoragePool>(), volumeInfo.getSize(), rootDiskHyperType);
|
||||
vol = createVolume(volumeInfo, vm, rootDiskTmplt, dcVO, pod, clusterId, hostId, svo, diskVO, new ArrayList<StoragePool>(), volumeInfo.getSize(), rootDiskHyperType);
|
||||
} else if (volumeInfo.getState() == Volume.State.Uploaded) {
|
||||
vol = copyVolume(storagePool, volumeInfo, vm, rootDiskTmplt, dcVO, pod, diskVO, svo, rootDiskHyperType);
|
||||
if (vol != null) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.cloud.hypervisor.dao;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -73,6 +74,12 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
|
|||
SearchCriteria<HypervisorCapabilitiesVO> sc = HypervisorTypeAndVersionSearch.create();
|
||||
sc.setParameters("hypervisorType", hypervisorType);
|
||||
sc.setParameters("hypervisorVersion", hypervisorVersion);
|
||||
HypervisorCapabilitiesVO result = findOneBy(sc);
|
||||
if (result != null || !HypervisorType.VMware.equals(hypervisorType) ||
|
||||
CloudStackVersion.getVMwareParentVersion(hypervisorVersion) == null) {
|
||||
return result;
|
||||
}
|
||||
sc.setParameters("hypervisorVersion", CloudStackVersion.getVMwareParentVersion(hypervisorVersion));
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
|
|||
@Basic(fetch = FetchType.LAZY)
|
||||
private String userData;
|
||||
|
||||
@Column(name = "user_data_id", nullable = true)
|
||||
private Long userDataId = null;
|
||||
|
||||
@Column(name = "user_data_details", updatable = true, length = 4096)
|
||||
private String userDataDetails;
|
||||
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
protected Date removed;
|
||||
|
||||
|
|
@ -228,6 +234,24 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
|
|||
return userData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getUserDataId() {
|
||||
return userDataId;
|
||||
}
|
||||
|
||||
public void setUserDataId(Long userDataId) {
|
||||
this.userDataId = userDataId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserDataDetails() {
|
||||
return userDataDetails;
|
||||
}
|
||||
|
||||
public void setUserDataDetails(String userDataDetails) {
|
||||
this.userDataDetails = userDataDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
|
|
@ -72,7 +73,7 @@ public class GuestOSHypervisorVO implements GuestOSHypervisor {
|
|||
|
||||
@Override
|
||||
public String getHypervisorType() {
|
||||
return hypervisorType;
|
||||
return Hypervisor.HypervisorType.getType(hypervisorType).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ public class GuestOSVO implements GuestOS {
|
|||
@Column(name = "is_user_defined")
|
||||
private boolean isUserDefined;
|
||||
|
||||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
|
|
@ -120,4 +123,15 @@ public class GuestOSVO implements GuestOS {
|
|||
public void setIsUserDefined(boolean isUserDefined) {
|
||||
this.isUserDefined = isUserDefined;
|
||||
}
|
||||
|
||||
public boolean getForDisplay() {
|
||||
return isDisplay();
|
||||
}
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,24 @@
|
|||
// under the License.
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface GuestOSDao extends GenericDao<GuestOSVO, Long> {
|
||||
|
||||
GuestOSVO listByDisplayName(String displayName);
|
||||
GuestOSVO findOneByDisplayName(String displayName);
|
||||
|
||||
List<GuestOSVO> listLikeDisplayName(String displayName);
|
||||
GuestOSVO findByCategoryIdAndDisplayNameOrderByCreatedDesc(long categoryId, String displayName);
|
||||
|
||||
Set<String> findDoubleNames();
|
||||
|
||||
List<GuestOSVO> listByDisplayName(String displayName);
|
||||
|
||||
Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(Long startIndex, Long pageSize, Long id, Long osCategoryId, String description, String keyword, Boolean forDisplay);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,19 @@
|
|||
package com.cloud.storage.dao;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -49,7 +60,7 @@ public class GuestOSDaoImpl extends GenericDaoBase<GuestOSVO, Long> implements G
|
|||
}
|
||||
|
||||
@Override
|
||||
public GuestOSVO listByDisplayName(String displayName) {
|
||||
public GuestOSVO findOneByDisplayName(String displayName) {
|
||||
SearchCriteria<GuestOSVO> sc = Search.create();
|
||||
sc.setParameters("display_name", displayName);
|
||||
return findOneBy(sc);
|
||||
|
|
@ -76,4 +87,69 @@ public class GuestOSDaoImpl extends GenericDaoBase<GuestOSVO, Long> implements G
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
+ "select display_name from"
|
||||
+ "(select display_name, count(1) as count from guest_os go1 where removed is null group by display_name having count > 1) tab0";
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@DB
|
||||
public Set<String> findDoubleNames() {
|
||||
String selectSql = "SELECT display_name FROM (SELECT display_name, count(1) AS count FROM guest_os go1 WHERE removed IS NULL GROUP BY display_name HAVING count > 1) tab0";
|
||||
Set<String> names = new HashSet<>();
|
||||
Connection conn = TransactionLegacy.getStandaloneConnection();
|
||||
try {
|
||||
PreparedStatement stmt = conn.prepareStatement(selectSql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs != null && rs.next()) {
|
||||
names.add(rs.getString(1));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new CloudRuntimeException("Error while trying to find duplicate guest OSses", ex);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all with a certain display name
|
||||
* @param displayName
|
||||
* @return a list with GuestOS objects
|
||||
*/
|
||||
@Override
|
||||
public List<GuestOSVO> listByDisplayName(String displayName) {
|
||||
SearchCriteria<GuestOSVO> sc = Search.create();
|
||||
sc.setParameters("display_name", displayName);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(Long startIndex, Long pageSize, Long id, Long osCategoryId, String description, String keyword, Boolean forDisplay) {
|
||||
final Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, startIndex, pageSize);
|
||||
final SearchCriteria<GuestOSVO> sc = createSearchCriteria();
|
||||
|
||||
if (id != null) {
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (osCategoryId != null) {
|
||||
sc.addAnd("categoryId", SearchCriteria.Op.EQ, osCategoryId);
|
||||
}
|
||||
|
||||
if (description != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + description + "%");
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
}
|
||||
|
||||
if (forDisplay != null) {
|
||||
sc.addAnd("display", SearchCriteria.Op.EQ, forDisplay);
|
||||
}
|
||||
|
||||
final Pair<List<GuestOSVO>, Integer> result = searchAndCount(sc, searchFilter);
|
||||
return new Pair<>(result.first(), result.second());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -24,7 +23,12 @@ import java.util.List;
|
|||
|
||||
public interface GuestOSHypervisorDao extends GenericDao<GuestOSHypervisorVO, Long> {
|
||||
|
||||
HypervisorType findHypervisorTypeByGuestOsId(long guestOsId);
|
||||
/**
|
||||
* list all the mappings for a guesos id
|
||||
* @param guestOsId the guestos to look for
|
||||
* @return a list of mappings
|
||||
*/
|
||||
List<GuestOSHypervisorVO> listByGuestOsId(long guestOsId);
|
||||
|
||||
GuestOSHypervisorVO findByOsIdAndHypervisor(long guestOsId, String hypervisorType, String hypervisorVersion);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.QueryBuilder;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.QueryBuilder;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -82,11 +81,10 @@ public class GuestOSHypervisorDaoImpl extends GenericDaoBase<GuestOSHypervisorVO
|
|||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType findHypervisorTypeByGuestOsId(long guestOsId) {
|
||||
public List<GuestOSHypervisorVO> listByGuestOsId(long guestOsId) {
|
||||
SearchCriteria<GuestOSHypervisorVO> sc = guestOsSearch.create();
|
||||
sc.setParameters("guest_os_id", guestOsId);
|
||||
GuestOSHypervisorVO goh = findOneBy(sc);
|
||||
return HypervisorType.getType(goh.getHypervisorType());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ import org.apache.log4j.Logger;
|
|||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -53,6 +55,89 @@ public class GuestOsMapper {
|
|||
guestOSDao = new GuestOSDaoImpl();
|
||||
}
|
||||
|
||||
public void mergeDuplicates() {
|
||||
LOG.info("merging duplicate guest osses");
|
||||
Set<Set<GuestOSVO>> duplicates = findDuplicates();
|
||||
LOG.debug(String.format("merging %d sets of duplicates", duplicates.size()));
|
||||
for (Set<GuestOSVO> setOfGuestOSes : duplicates) {
|
||||
// decide which to (mark as) remove(d)
|
||||
// # highest/lowest id
|
||||
// # or is user_defined == false
|
||||
GuestOSVO guestOSVO = highestIdFrom(setOfGuestOSes);
|
||||
LOG.info(String.format("merging %d duplicates for %s ", setOfGuestOSes.size(), guestOSVO.getDisplayName()));
|
||||
makeNormative(guestOSVO, setOfGuestOSes);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void makeNormative(GuestOSVO guestOSVO, Set<GuestOSVO> setOfGuestOSes) {
|
||||
for (GuestOSVO oldGuestOs : setOfGuestOSes) {
|
||||
if (guestOSVO.getId() != oldGuestOs.getId()) {
|
||||
List<GuestOSHypervisorVO> mappings = guestOSHypervisorDao.listByGuestOsId(oldGuestOs.getId());
|
||||
copyMappings(guestOSVO, mappings);
|
||||
makeHidden(oldGuestOs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeHidden(GuestOSVO guestOSVO) {
|
||||
guestOSVO.setDisplay(false);
|
||||
guestOSDao.update(guestOSVO.getId(),guestOSVO);
|
||||
}
|
||||
|
||||
private void copyMappings(GuestOSVO guestOSVO, List<GuestOSHypervisorVO> mappings) {
|
||||
for (GuestOSHypervisorVO mapping : mappings) {
|
||||
if (null == guestOSHypervisorDao.findByOsIdAndHypervisor(guestOSVO.getId(), mapping.getHypervisorType(), mapping.getHypervisorVersion())) {
|
||||
GuestOSHypervisorVO newMap = new GuestOSHypervisorVO();
|
||||
newMap.setGuestOsId(guestOSVO.getId());
|
||||
newMap.setGuestOsName(mapping.getGuestOsName());
|
||||
newMap.setHypervisorType(mapping.getHypervisorType());
|
||||
newMap.setHypervisorVersion(mapping.getHypervisorVersion());
|
||||
guestOSHypervisorDao.persist(newMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GuestOSVO highestIdFrom(Set<GuestOSVO> setOfGuestOSes) {
|
||||
GuestOSVO rc = null;
|
||||
for (GuestOSVO guestOSVO: setOfGuestOSes) {
|
||||
if (rc == null || (guestOSVO.getId() > rc.getId() && !guestOSVO.getIsUserDefined())) {
|
||||
rc = guestOSVO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
¨¨¨
|
||||
select * from guest_os go2
|
||||
where display_name
|
||||
in (select display_name from
|
||||
(select display_name, count(1) as count from guest_os go1 group by display_name having count > 1) tab0);
|
||||
¨¨¨
|
||||
* and group them by display_name
|
||||
*
|
||||
*
|
||||
* @return a list of sets of duplicate
|
||||
*/
|
||||
private Set<Set<GuestOSVO>> findDuplicates() {
|
||||
Set<Set<GuestOSVO>> rc = new HashSet<>();
|
||||
Set<String> names = guestOSDao.findDoubleNames();
|
||||
for (String name : names) {
|
||||
List<GuestOSVO> guestOsses = guestOSDao.listByDisplayName(name);
|
||||
if (CollectionUtils.isNotEmpty(guestOsses)) {
|
||||
rc.add(new HashSet<>(guestOsses));
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
public List<GuestOSVO> listByDisplayName(String displayName) {
|
||||
return guestOSDao.listByDisplayName(displayName);
|
||||
}
|
||||
|
||||
private long getGuestOsId(long categoryId, String displayName) {
|
||||
GuestOSVO guestOS = guestOSDao.findByCategoryIdAndDisplayNameOrderByCreatedDesc(categoryId, displayName);
|
||||
long id = 0l;
|
||||
|
|
@ -76,26 +161,33 @@ public class GuestOsMapper {
|
|||
}
|
||||
|
||||
public void addGuestOsAndHypervisorMappings(long categoryId, String displayName, List<GuestOSHypervisorMapping> mappings) {
|
||||
if (!addGuestOs(categoryId, displayName)) {
|
||||
LOG.warn("Couldn't add the guest OS with category id: " + categoryId + " and display name: " + displayName);
|
||||
return;
|
||||
long guestOsId = getGuestOsId(categoryId, displayName);
|
||||
if (guestOsId == 0) {
|
||||
LOG.debug("No guest OS found with category id: " + categoryId + " and display name: " + displayName);
|
||||
if (!addGuestOs(categoryId, displayName)) {
|
||||
LOG.warn("Couldn't add the guest OS with category id: " + categoryId + " and display name: " + displayName);
|
||||
return;
|
||||
}
|
||||
guestOsId = getGuestOsId(categoryId, displayName);
|
||||
} else {
|
||||
updateToSystemDefined(guestOsId);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(mappings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long guestOsId = getGuestOsId(categoryId, displayName);
|
||||
if (guestOsId == 0) {
|
||||
LOG.debug("No guest OS found with category id: " + categoryId + " and display name: " + displayName);
|
||||
return;
|
||||
}
|
||||
|
||||
for (final GuestOSHypervisorMapping mapping : mappings) {
|
||||
addGuestOsHypervisorMapping(mapping, guestOsId);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateToSystemDefined(long guestOsId) {
|
||||
GuestOSVO guestOsVo = guestOSDao.findById(guestOsId);
|
||||
guestOsVo.setIsUserDefined(false);
|
||||
guestOSDao.update(guestOsId, guestOsVo);// TODO: update is_user_defined to false
|
||||
}
|
||||
|
||||
public boolean addGuestOs(long categoryId, String displayName) {
|
||||
LOG.debug("Adding guest OS with category id: " + categoryId + " and display name: " + displayName);
|
||||
GuestOSVO guestOS = new GuestOSVO();
|
||||
|
|
@ -229,4 +321,20 @@ public class GuestOsMapper {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateGuestOsNameInHypervisorMapping(long categoryId, String displayName, GuestOSHypervisorMapping mapping) {
|
||||
if (!isValidGuestOSHypervisorMapping(mapping)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long guestOsId = getGuestOsId(categoryId, displayName);
|
||||
if (guestOsId == 0) {
|
||||
LOG.error(String.format("no guest os found for category %d and name %s, skipping mapping it to %s/%s", guestOsId, displayName, mapping.getHypervisorType(), mapping.getHypervisorVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
GuestOSHypervisorVO guestOsMapping = guestOSHypervisorDao.findByOsIdAndHypervisor(guestOsId, mapping.getHypervisorType(), mapping.getHypervisorVersion());
|
||||
guestOsMapping.setGuestOsName(mapping.getGuestOsName());
|
||||
guestOSHypervisorDao.update(guestOsMapping.getId(), guestOsMapping);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
// under the License.
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.GuestOSHypervisorMapping;
|
||||
import com.cloud.upgrade.GuestOsMapper;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -23,10 +27,13 @@ import org.apache.log4j.Logger;
|
|||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41800to41810.class);
|
||||
private GuestOsMapper guestOsMapper = new GuestOsMapper();
|
||||
|
||||
private SystemVmTemplateRegistration systemVmTemplateRegistration;
|
||||
|
||||
@Override
|
||||
|
|
@ -58,6 +65,17 @@ public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
fixForeignKeyNames(conn);
|
||||
updateGuestOsMappings(conn);
|
||||
copyGuestOsMappingsToVMware80u1();
|
||||
addForeignKeyToAutoscaleVmprofiles(conn);
|
||||
mergeDuplicateGuestOSes();
|
||||
}
|
||||
|
||||
private void mergeDuplicateGuestOSes() {
|
||||
guestOsMapper.mergeDuplicates();
|
||||
List<GuestOSVO> nines = guestOsMapper.listByDisplayName("Red Hat Enterprise Linux 9");
|
||||
GuestOSVO nineDotZero = guestOsMapper.listByDisplayName("Red Hat Enterprise Linux 9.0").get(0);
|
||||
guestOsMapper.makeNormative(nineDotZero, new HashSet<>(nines));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -86,6 +104,115 @@ public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
}
|
||||
}
|
||||
|
||||
private void updateGuestOsMappings(Connection conn) {
|
||||
LOG.debug("Updating guest OS mappings");
|
||||
|
||||
GuestOsMapper guestOsMapper = new GuestOsMapper();
|
||||
List<GuestOSHypervisorMapping> mappings = new ArrayList<>();
|
||||
|
||||
LOG.debug("Adding Ubuntu 20.04 support for VMware 6.5+");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.5", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.1", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.2", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.3", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.1.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.2.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.3.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "8.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS");
|
||||
|
||||
LOG.debug("Adding Ubuntu 22.04 support for KVM and VMware 6.5+");
|
||||
mappings.add(new GuestOSHypervisorMapping("KVM", "default", "Ubuntu 22.04 LTS"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "6.5", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "6.7", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.1", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.2", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.3", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "7.0", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.1.0", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.2.0", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.3.0", "ubuntu64Guest"));
|
||||
mappings.add(new GuestOSHypervisorMapping("VMware", "8.0", "ubuntu64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(10, "Ubuntu 22.04 LTS", mappings);
|
||||
mappings.clear();
|
||||
|
||||
LOG.debug("Correcting guest OS names in hypervisor mappings for VMware 8.0 ad 8.0.0.1");
|
||||
final String hypervisorVMware = Hypervisor.HypervisorType.VMware.name();
|
||||
final String hypervisorVersionVmware8 = "8.0";
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "AlmaLinux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "almalinux_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Oracle Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "oracleLinux9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Rocky Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "rockylinux_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "AlmaLinux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "almalinux_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Oracle Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "oracleLinux9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Rocky Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "rockylinux_64Guest"));
|
||||
|
||||
LOG.debug("Correcting guest OS names in hypervisor mappings for Red Hat Enterprise Linux 9");
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0", "rhel9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.1.0", "rhel9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.2.0", "rhel9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.3.0", "rhel9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "rhel9_64Guest"));
|
||||
guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "rhel9_64Guest"));
|
||||
|
||||
LOG.debug("Adding new guest OS ids in hypervisor mappings for VMware 8.0");
|
||||
// Add support for darwin22_64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "darwin22_64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(7, "macOS 13 (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for darwin23_64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "darwin23_64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(7, "macOS 14 (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for debian12_64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "debian12_64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(2, "Debian GNU/Linux 12 (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for debian12Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "debian12Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(2, "Debian GNU/Linux 12 (32-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for freebsd14_64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "freebsd14_64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(9, "FreeBSD 14 (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for freebsd14Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "freebsd14Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(9, "FreeBSD 14 (32-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for other6xLinux64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "other6xLinux64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(7, "Linux 6.x Kernel (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for other6xLinuxGuest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "other6xLinuxGuest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(7, "Linux 6.x Kernel (32-bit)", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for vmkernel8Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "vmkernel8Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(7, "VMware ESXi 8.0", mappings);
|
||||
mappings.clear();
|
||||
|
||||
// Add support for windows11_64Guest from VMware 8.0
|
||||
mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "windows11_64Guest"));
|
||||
guestOsMapper.addGuestOsAndHypervisorMappings(6, "Windows 11 (64-bit)", mappings);
|
||||
mappings.clear();
|
||||
}
|
||||
|
||||
private void copyGuestOsMappingsToVMware80u1() {
|
||||
LOG.debug("Copying guest OS mappings from VMware 8.0 to VMware 8.0.1");
|
||||
GuestOsMapper guestOsMapper = new GuestOsMapper();
|
||||
guestOsMapper.copyGuestOSHypervisorMappings(Hypervisor.HypervisorType.VMware, "8.0", "8.0.1");
|
||||
}
|
||||
|
||||
private void fixForeignKeyNames(Connection conn) {
|
||||
//Alter foreign key name for user_vm table from fk_user_data_id to fk_user_vm__user_data_id (if exists)
|
||||
List<String> keys = new ArrayList<String>();
|
||||
|
|
@ -111,4 +238,8 @@ public class Upgrade41800to41810 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
DbUpgradeUtils.dropKeysIfExist(conn, "cloud.volumes", keys, false);
|
||||
DbUpgradeUtils.addForeignKey(conn, "volumes", "passphrase_id","passphrase", "id");
|
||||
}
|
||||
|
||||
private void addForeignKeyToAutoscaleVmprofiles(Connection conn) {
|
||||
DbUpgradeUtils.addForeignKey(conn, "autoscale_vmprofiles", "user_data_id", "user_data", "id");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,27 @@
|
|||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
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.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Upgrade41810to41900 implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41810to41900.class);
|
||||
private SystemVmTemplateRegistration systemVmTemplateRegistration;
|
||||
|
||||
private final SimpleDateFormat[] formats = {
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"), new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"),
|
||||
new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy")};
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] {"4.18.1.0", "4.19.0.0"};
|
||||
|
|
@ -55,6 +66,7 @@ public class Upgrade41810to41900 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
migrateBackupDates(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -82,4 +94,103 @@ public class Upgrade41810to41900 implements DbUpgrade, DbUpgradeSystemVmTemplate
|
|||
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
|
||||
}
|
||||
}
|
||||
|
||||
public void migrateBackupDates(Connection conn) {
|
||||
LOG.info("Trying to convert backups' date column from varchar(255) to datetime type.");
|
||||
|
||||
modifyDateColumnNameAndCreateNewOne(conn);
|
||||
fetchDatesAndMigrateToNewColumn(conn);
|
||||
dropOldColumn(conn);
|
||||
|
||||
LOG.info("Finished converting backups' date column from varchar(255) to datetime.");
|
||||
}
|
||||
|
||||
private void modifyDateColumnNameAndCreateNewOne(Connection conn) {
|
||||
String alterColumnName = "ALTER TABLE `cloud`.`backups` CHANGE COLUMN `date` `old_date` varchar(255);";
|
||||
try (PreparedStatement pstmt = conn.prepareStatement(alterColumnName)) {
|
||||
pstmt.execute();
|
||||
} catch (SQLException e) {
|
||||
String message = String.format("Unable to alter backups' date column name due to [%s].", e.getMessage());
|
||||
LOG.error(message, e);
|
||||
throw new CloudRuntimeException(message, e);
|
||||
}
|
||||
|
||||
String createNewColumn = "ALTER TABLE `cloud`.`backups` ADD COLUMN `date` DATETIME;";
|
||||
try (PreparedStatement pstmt = conn.prepareStatement(createNewColumn)) {
|
||||
pstmt.execute();
|
||||
} catch (SQLException e) {
|
||||
String message = String.format("Unable to crate new backups' column date due to [%s].", e.getMessage());
|
||||
LOG.error(message, e);
|
||||
throw new CloudRuntimeException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDatesAndMigrateToNewColumn(Connection conn) {
|
||||
String selectBackupDates = "SELECT `id`, `old_date` FROM `cloud`.`backups` WHERE 1;";
|
||||
String date;
|
||||
java.sql.Date reformatedDate;
|
||||
|
||||
try (PreparedStatement pstmt = conn.prepareStatement(selectBackupDates)) {
|
||||
try (ResultSet result = pstmt.executeQuery()) {
|
||||
while (result.next()) {
|
||||
date = result.getString("old_date");
|
||||
reformatedDate = tryToTransformStringToDate(date);
|
||||
updateBackupDate(conn, result.getLong("id"), reformatedDate);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String message = String.format("Unable to retrieve backup dates due to [%s].", e.getMessage());
|
||||
LOG.error(message, e);
|
||||
throw new CloudRuntimeException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
private java.sql.Date tryToTransformStringToDate(String date) {
|
||||
Date parsedDate = null;
|
||||
try {
|
||||
parsedDate = DateUtil.parseTZDateString(date);
|
||||
} catch (ParseException e) {
|
||||
for (SimpleDateFormat sdf: formats) {
|
||||
try {
|
||||
parsedDate = sdf.parse(date);
|
||||
} catch (ParseException ex) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (parsedDate == null) {
|
||||
String msg = String.format("Unable to parse date [%s]. Will change backup date to null.", date);
|
||||
LOG.error(msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new java.sql.Date(parsedDate.getTime());
|
||||
}
|
||||
|
||||
private void updateBackupDate(Connection conn, long id, java.sql.Date date) {
|
||||
String updateBackupDate = "UPDATE `cloud`.`backups` SET `date` = ? WHERE `id` = ?;";
|
||||
try (PreparedStatement pstmt = conn.prepareStatement(updateBackupDate)) {
|
||||
pstmt.setDate(1, date);
|
||||
pstmt.setLong(2, id);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
String message = String.format("Unable to update backup date with id [%s] to date [%s] due to [%s].", id, date, e.getMessage());
|
||||
LOG.error(message, e);
|
||||
throw new CloudRuntimeException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropOldColumn(Connection conn) {
|
||||
String dropOldColumn = "ALTER TABLE `cloud`.`backups` DROP COLUMN `old_date`;";
|
||||
try (PreparedStatement pstmt = conn.prepareStatement(dropOldColumn)) {
|
||||
pstmt.execute();
|
||||
} catch (SQLException e) {
|
||||
String message = String.format("Unable to drop old_date column due to [%s].", e.getMessage());
|
||||
LOG.error(message, e);
|
||||
throw new CloudRuntimeException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.cloudstack.backup;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -27,6 +28,8 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "backups")
|
||||
|
|
@ -49,7 +52,8 @@ public class BackupVO implements Backup {
|
|||
private String backupType;
|
||||
|
||||
@Column(name = "date")
|
||||
private String date;
|
||||
@Temporal(value = TemporalType.DATE)
|
||||
private Date date;
|
||||
|
||||
@Column(name = "size")
|
||||
private Long size;
|
||||
|
|
@ -114,11 +118,11 @@ public class BackupVO implements Backup {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDate() {
|
||||
return date;
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1569,3 +1569,5 @@ SET
|
|||
usage_type = 22
|
||||
WHERE
|
||||
usage_type = 24 AND usage_display like '% io write';
|
||||
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os', 'display', 'tinyint(1) DEFAULT ''1'' COMMENT ''should this guest_os be shown to the end user'' ');
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
-- Schema upgrade from 4.18.0.0 to 4.18.1.0
|
||||
--;
|
||||
|
||||
-- Add support for VMware 8.0u1 (8.0.1.x)
|
||||
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '8.0.1', 1024, 0, 59, 64, 1, 1);
|
||||
|
||||
-- Update conserve_mode of the default network offering for Tungsten Fabric (this fixes issue #7241)
|
||||
UPDATE `cloud`.`network_offerings` SET conserve_mode = 0 WHERE unique_name ='DefaultTungstenFarbicNetworkOffering';
|
||||
|
||||
|
|
@ -32,7 +35,15 @@ CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'VM
|
|||
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'VMware', '8.0.0.1', 'windows2019srvNext_64Guest');
|
||||
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'Xenserver', '8.2.0', 'Windows Server 2022 (64-bit)');
|
||||
|
||||
-- Support userdata ids and details in VM AutoScaling
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.autoscale_vmprofiles', 'user_data_id', 'bigint unsigned DEFAULT NULL COMMENT "id of the user data" AFTER `user_data`');
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.autoscale_vmprofiles', 'user_data_details', 'mediumtext DEFAULT NULL COMMENT "value of the comma-separated list of parameters" AFTER `user_data_id`');
|
||||
|
||||
-- Don't enable CPU cap for default system offerings, fixes regression from https://github.com/apache/cloudstack/pull/6420
|
||||
UPDATE `cloud`.`service_offering` so
|
||||
SET so.limit_cpu_use = 0
|
||||
WHERE so.default_use = 1 AND so.vm_type IN ('domainrouter', 'secondarystoragevm', 'consoleproxy', 'internalloadbalancervm', 'elasticloadbalancervm');
|
||||
|
||||
-- fix erronous commas in guest_os names
|
||||
UPDATE `cloud`.`guest_os_hypervisor` SET guest_os_name = 'rhel9_64Guest' WHERE guest_os_name = 'rhel9_64Guest,';
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os', 'display', 'tinyint(1) DEFAULT ''1'' COMMENT ''should this guest_os be shown to the end user'' ');
|
||||
|
|
|
|||
|
|
@ -26,6 +26,18 @@ import org.junit.Test;
|
|||
|
||||
public class AutoScaleVmProfileVOTest {
|
||||
|
||||
static long zoneId = 1L;
|
||||
static long domainId = 2L;
|
||||
static long accountId = 3L;
|
||||
static long serviceOfferingId = 4L;
|
||||
static long templateId = 5L;
|
||||
static String userdata = "userdata";
|
||||
static long userdataId = 6L;
|
||||
static String userdataDetails = "userdataDetails";
|
||||
static String userdataNew = "userdataNew";
|
||||
|
||||
static long autoScaleUserId = 7L;
|
||||
|
||||
@Test
|
||||
public void testCounterParamsForUpdate() {
|
||||
AutoScaleVmProfileVO profile = new AutoScaleVmProfileVO();
|
||||
|
|
@ -62,4 +74,23 @@ public class AutoScaleVmProfileVOTest {
|
|||
Assert.assertEquals("rootdisksize", otherDeployParamsList.get(1).first());
|
||||
Assert.assertEquals("10", otherDeployParamsList.get(1).second());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperties() {
|
||||
AutoScaleVmProfileVO profile = new AutoScaleVmProfileVO(zoneId, domainId, accountId, serviceOfferingId, templateId, null, null, userdata, null, autoScaleUserId);
|
||||
Assert.assertEquals(new Long(zoneId), profile.getZoneId());
|
||||
Assert.assertEquals(domainId, profile.getDomainId());
|
||||
Assert.assertEquals(accountId, profile.getAccountId());
|
||||
Assert.assertEquals(new Long(serviceOfferingId), profile.getServiceOfferingId());
|
||||
Assert.assertEquals(new Long(templateId), profile.getTemplateId());
|
||||
Assert.assertEquals(userdata, profile.getUserData());
|
||||
Assert.assertEquals(new Long(autoScaleUserId), profile.getAutoScaleUserId());
|
||||
|
||||
profile.setUserData(userdataNew);
|
||||
profile.setUserDataId(userdataId);
|
||||
profile.setUserDataDetails(userdataDetails);
|
||||
Assert.assertEquals(userdataNew, profile.getUserData());
|
||||
Assert.assertEquals(new Long(userdataId), profile.getUserDataId());
|
||||
Assert.assertEquals(userdataDetails, profile.getUserDataDetails());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@
|
|||
<property name="name" value="KVM Agent"/>
|
||||
</bean>
|
||||
|
||||
<bean id="CustomServerDiscoverer"
|
||||
class="com.cloud.hypervisor.discoverer.CustomServerDiscoverer">
|
||||
<property name="name" value="CustomHW Agent" />
|
||||
</bean>
|
||||
|
||||
<bean id="BareMetalDiscoverer" class="com.cloud.baremetal.BareMetalDiscoverer">
|
||||
<property name="name" value="Bare Metal Agent"/>
|
||||
</bean>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ intelligent IaaS cloud implementation.
|
|||
%package management
|
||||
Summary: CloudStack management server UI
|
||||
Requires: java-11-openjdk
|
||||
Requires: tzdata-java
|
||||
Requires: (tzdata-java or timezone-java)
|
||||
Requires: python3
|
||||
Requires: bash
|
||||
Requires: gawk
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
if (roleService.isEnabled()) {
|
||||
LOGGER.debug("RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker.");
|
||||
}
|
||||
return roleService.isEnabled();
|
||||
return !roleService.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getApisAllowedToUser(Role role, User user, List<String> apiNames) throws PermissionDeniedException {
|
||||
if (isEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
return apiNames;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
|
||||
@Override
|
||||
public boolean checkAccess(User user, String commandName) throws PermissionDeniedException {
|
||||
if (isEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +107,10 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
|||
|
||||
@Override
|
||||
public boolean checkAccess(Account account, String commandName) {
|
||||
if (!isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RoleType roleType = accountService.getRoleType(account);
|
||||
if (isApiAllowed(commandName, roleType)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.mockito.InjectMocks;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -47,7 +47,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class NonStrictHostAntiAffinityProcessorTest {
|
||||
|
||||
@Spy
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ResetApiLimitCmd extends BaseCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
@ACL
|
||||
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.UUID, entityType = AccountResponse.class, description = "the ID of the acount whose limit to be reset")
|
||||
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.UUID, entityType = AccountResponse.class, description = "the ID of the account whose limit to be reset")
|
||||
private Long accountId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class DummyBackupProvider extends AdapterBase implements BackupProvider {
|
|||
backup.setVmId(vm.getId());
|
||||
backup.setExternalId("dummy-external-id");
|
||||
backup.setType("FULL");
|
||||
backup.setDate(new Date().toString());
|
||||
backup.setDate(new Date());
|
||||
backup.setSize(1024L);
|
||||
backup.setProtectedSize(1024000L);
|
||||
backup.setStatus(Backup.Status.BackedUp);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ import javax.inject.Inject;
|
|||
import java.net.URISyntaxException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -605,7 +607,14 @@ public class NetworkerBackupProvider extends AdapterBase implements BackupProvid
|
|||
strayBackup.setVmId(vm.getId());
|
||||
strayBackup.setExternalId(strayNetworkerBackup.getId());
|
||||
strayBackup.setType(strayNetworkerBackup.getType());
|
||||
strayBackup.setDate(strayNetworkerBackup.getSaveTime());
|
||||
SimpleDateFormat formatterDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
try {
|
||||
strayBackup.setDate(formatterDateTime.parse(strayNetworkerBackup.getSaveTime()));
|
||||
} catch (ParseException e) {
|
||||
String msg = String.format("Unable to parse date [%s].", strayNetworkerBackup.getSaveTime());
|
||||
LOG.error(msg, e);
|
||||
throw new CloudRuntimeException(msg, e);
|
||||
}
|
||||
strayBackup.setStatus(Backup.Status.BackedUp);
|
||||
for ( Backup.VolumeInfo thisVMVol : vm.getBackupVolumeList()) {
|
||||
vmBackupSize += (thisVMVol.getSize() / 1024L /1024L);
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ public class NetworkerClient {
|
|||
|
||||
SimpleDateFormat formatterDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat formatterTime = new SimpleDateFormat("HH:mm:ss");
|
||||
SimpleDateFormat formatterDateTime = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss");
|
||||
SimpleDateFormat formatterDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
|
||||
String startDate = formatterDate.format(backupJobStart);
|
||||
String startTime = formatterTime.format(backupJobStart);
|
||||
|
|
@ -252,7 +252,13 @@ public class NetworkerClient {
|
|||
backup.setVmId(vm.getId());
|
||||
backup.setExternalId(networkerLatestBackup.getId());
|
||||
backup.setType(networkerLatestBackup.getType());
|
||||
backup.setDate(networkerLatestBackup.getCreationTime());
|
||||
try {
|
||||
backup.setDate(formatterDateTime.parse(networkerLatestBackup.getCreationTime()));
|
||||
} catch (ParseException e) {
|
||||
String msg = String.format("Unable to parse date [%s].", networkerLatestBackup.getCreationTime());
|
||||
LOG.error(msg, e);
|
||||
throw new CloudRuntimeException(msg, e);
|
||||
}
|
||||
backup.setSize(networkerLatestBackup.getSize().getValue());
|
||||
backup.setProtectedSize(networkerLatestBackup.getSize().getValue());
|
||||
backup.setStatus(org.apache.cloudstack.backup.Backup.Status.BackedUp);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.UUID;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
|
@ -660,7 +662,7 @@ public class VeeamClient {
|
|||
private Backup.RestorePoint getRestorePointFromBlock(String[] parts) {
|
||||
LOG.debug(String.format("Processing block of restore points: [%s].", StringUtils.join(parts, ", ")));
|
||||
String id = null;
|
||||
String created = null;
|
||||
Date created = null;
|
||||
String type = null;
|
||||
for (String part : parts) {
|
||||
if (part.matches("Id(\\s)+:(.)*")) {
|
||||
|
|
@ -668,7 +670,11 @@ public class VeeamClient {
|
|||
id = split[1].trim();
|
||||
} else if (part.matches("CreationTime(\\s)+:(.)*")) {
|
||||
String [] split = part.split(":", 2);
|
||||
created = split[1].trim();
|
||||
split[1] = StringUtils.trim(split[1]);
|
||||
String [] time = split[1].split("[:/ ]");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Integer.parseInt(time[2]), Integer.parseInt(time[0]) - 1, Integer.parseInt(time[1]), Integer.parseInt(time[3]), Integer.parseInt(time[4]), Integer.parseInt(time[5]));
|
||||
created = cal.getTime();
|
||||
} else if (part.matches("Type(\\s)+:(.)*")) {
|
||||
String [] split = part.split(":");
|
||||
type = split[1].trim();
|
||||
|
|
|
|||
|
|
@ -456,8 +456,8 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
|||
*/
|
||||
private Long getImportingVMGuestOs(VirtualMachineConfigSummary configSummary) {
|
||||
String guestFullName = configSummary.getGuestFullName();
|
||||
GuestOSVO os = _guestOsDao.listByDisplayName(guestFullName);
|
||||
return os != null ? os.getId() : _guestOsDao.listByDisplayName("Other (64-bit)").getId();
|
||||
GuestOSVO os = _guestOsDao.findOneByDisplayName(guestFullName);
|
||||
return os != null ? os.getId() : _guestOsDao.findOneByDisplayName("Other (64-bit)").getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import com.cloud.vm.dao.DomainRouterDao;
|
|||
import com.cloud.vm.dao.NicDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper;
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -165,7 +166,7 @@ class VmwareVmImplementer {
|
|||
|
||||
GuestOSHypervisorVO guestOsMapping = null;
|
||||
if (host != null) {
|
||||
guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), host.getHypervisorVersion());
|
||||
guestOsMapping = getGuestOsMapping(guestOS, host.getHypervisorVersion());
|
||||
}
|
||||
if (guestOsMapping == null || host == null) {
|
||||
to.setPlatformEmulator(null);
|
||||
|
|
@ -405,4 +406,17 @@ class VmwareVmImplementer {
|
|||
|
||||
return listForSort.toArray(new NicTO[0]);
|
||||
}
|
||||
|
||||
protected GuestOSHypervisorVO getGuestOsMapping(GuestOSVO guestOS , String hypervisorVersion) {
|
||||
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), hypervisorVersion);
|
||||
if (guestOsMapping == null) {
|
||||
LOGGER.debug(String.format("Cannot find guest os mappings for guest os \"%s\" on VMware %s", guestOS.getDisplayName(), hypervisorVersion));
|
||||
String parentVersion = CloudStackVersion.getVMwareParentVersion(hypervisorVersion);
|
||||
if (parentVersion != null) {
|
||||
guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), parentVersion);
|
||||
LOGGER.debug(String.format("Found guest os mappings for guest os \"%s\" on VMware %s: %s", guestOS.getDisplayName(), parentVersion, guestOsMapping));
|
||||
}
|
||||
}
|
||||
return guestOsMapping;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2636,7 +2636,9 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
|
|||
//
|
||||
// Power-on VM
|
||||
//
|
||||
if (!vmMo.powerOn()) {
|
||||
if (powerOnVM(vmMo, vmInternalCSName, vmNameOnVcenter)) {
|
||||
s_logger.debug(String.format("VM %s has been started successfully with hostname %s.", vmInternalCSName, vmNameOnVcenter));
|
||||
} else {
|
||||
throw new Exception("Failed to start VM. vmName: " + vmInternalCSName + " with hostname " + vmNameOnVcenter);
|
||||
}
|
||||
|
||||
|
|
@ -2708,6 +2710,23 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
|
|||
}
|
||||
}
|
||||
|
||||
private boolean powerOnVM(final VirtualMachineMO vmMo, final String vmInternalCSName, final String vmNameOnVcenter) throws Exception {
|
||||
int retry = 20;
|
||||
while (retry-- > 0) {
|
||||
try {
|
||||
return vmMo.powerOn();
|
||||
} catch (Exception e) {
|
||||
s_logger.info(String.format("Got exception while power on VM %s with hostname %s", vmInternalCSName, vmNameOnVcenter), e);
|
||||
if (e.getMessage() != null && e.getMessage().contains("File system specific implementation of Ioctl[file] failed")) {
|
||||
s_logger.debug(String.format("Failed to power on VM %s with hostname %s. Retrying", vmInternalCSName, vmNameOnVcenter));
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean multipleIsosAtached(DiskTO[] sortedDisks) {
|
||||
return Arrays.stream(sortedDisks).filter(disk -> disk.getType() == Volume.Type.ISO).count() > 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -37,6 +38,9 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.dao.GuestOSHypervisorDao;
|
||||
import com.cloud.vm.VmDetailConstants;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
|
|
@ -50,6 +54,9 @@ public class VmwareVmImplementerTest {
|
|||
@Mock
|
||||
VirtualMachineTO vmTO;
|
||||
|
||||
@Mock
|
||||
GuestOSHypervisorDao guestOsHypervisorDao;
|
||||
|
||||
private Map<String,String> vmDetails = new HashMap<String, String>();
|
||||
|
||||
AutoCloseable closeable;
|
||||
|
|
@ -150,4 +157,43 @@ public class VmwareVmImplementerTest {
|
|||
executeAndVerifyTest(false, false, "false", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGuestOsMapping1() {
|
||||
GuestOSVO guestOs = Mockito.mock(GuestOSVO.class);
|
||||
GuestOSHypervisorVO guestOsMapping = Mockito.mock(GuestOSHypervisorVO.class);
|
||||
Mockito.when(guestOs.getId()).thenReturn(200L);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(guestOsMapping);
|
||||
GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0");
|
||||
Assert.assertEquals(guestOsMapping, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGuestOsMapping2() {
|
||||
GuestOSVO guestOs = Mockito.mock(GuestOSVO.class);
|
||||
GuestOSHypervisorVO guestOsMapping = Mockito.mock(GuestOSHypervisorVO.class);
|
||||
Mockito.when(guestOs.getId()).thenReturn(200L);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(null);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1")).thenReturn(guestOsMapping);
|
||||
GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0");
|
||||
Assert.assertEquals(guestOsMapping, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGuestOsMapping3() {
|
||||
GuestOSVO guestOs = Mockito.mock(GuestOSVO.class);
|
||||
Mockito.when(guestOs.getId()).thenReturn(200L);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(null);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1")).thenReturn(null);
|
||||
GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0");
|
||||
Assert.assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGuestOsMapping4() {
|
||||
GuestOSVO guestOs = Mockito.mock(GuestOSVO.class);
|
||||
Mockito.when(guestOs.getId()).thenReturn(200L);
|
||||
Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0")).thenReturn(null);
|
||||
GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0");
|
||||
Assert.assertNull(result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,8 +682,10 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements
|
|||
final Float cpuDisableThreshold = DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.valueIn(clusterId);
|
||||
final Float memoryDisableThreshold = DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.valueIn(clusterId);
|
||||
|
||||
Long upInstances = 0L;
|
||||
Long totalInstances = 0L;
|
||||
long upInstances = 0L;
|
||||
long totalInstances = 0L;
|
||||
long upSystemInstances = 0L;
|
||||
long totalSystemInstances = 0L;
|
||||
for (final VMInstanceVO instance: vmInstanceDao.listByHostId(hostId)) {
|
||||
if (instance == null) {
|
||||
continue;
|
||||
|
|
@ -693,10 +695,16 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements
|
|||
if (instance.getState() == VirtualMachine.State.Running) {
|
||||
upInstances++;
|
||||
}
|
||||
} else if (instance.getType().isUsedBySystem()) {
|
||||
totalSystemInstances++;
|
||||
if (instance.getState() == VirtualMachine.State.Running) {
|
||||
upSystemInstances++;
|
||||
}
|
||||
}
|
||||
}
|
||||
metricsResponse.setPowerState(hostResponse.getOutOfBandManagementResponse().getPowerState());
|
||||
metricsResponse.setInstances(upInstances, totalInstances);
|
||||
metricsResponse.setSystemInstances(upSystemInstances, totalSystemInstances);
|
||||
metricsResponse.setCpuTotal(hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
|
||||
metricsResponse.setCpuUsed(hostResponse.getCpuUsed(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
|
||||
metricsResponse.setCpuAllocated(hostResponse.getCpuAllocated(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ public class HostMetricsResponse extends HostResponse {
|
|||
@Param(description = "instances on the host")
|
||||
private String instances;
|
||||
|
||||
@SerializedName("systeminstances")
|
||||
@Param(description = "system vm instances on the host")
|
||||
private String systemInstances;
|
||||
|
||||
@SerializedName("cputotalghz")
|
||||
@Param(description = "the total cpu capacity in Ghz")
|
||||
private String cpuTotal;
|
||||
|
|
@ -108,10 +112,12 @@ public class HostMetricsResponse extends HostResponse {
|
|||
this.powerState = powerState;
|
||||
}
|
||||
|
||||
public void setInstances(final Long running, final Long total) {
|
||||
if (running != null && total != null) {
|
||||
this.instances = String.format("%d / %d", running, total);
|
||||
}
|
||||
public void setSystemInstances(final long running, final long total) {
|
||||
this.systemInstances = String.format("%d / %d", running, total);
|
||||
}
|
||||
|
||||
public void setInstances(final long running, final long total) {
|
||||
this.instances = String.format("%d / %d", running, total);
|
||||
}
|
||||
|
||||
public void setCpuTotal(final Integer cpuNumber, final Long cpuSpeed) {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ under the License.
|
|||
<adapter name="XCP Agent" class="com.cloud.hypervisor.xenserver.discoverer.XcpServerDiscoverer"/>
|
||||
<adapter name="SecondaryStorage" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer"/>
|
||||
<adapter name="KVM Agent" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer"/>
|
||||
<adapter name="CustomHW Agent" class="com.cloud.hypervisor.discoverer.CustomServerDiscoverer"/>
|
||||
<adapter name="Bare Metal Agent" class="com.cloud.baremetal.BareMetalDiscoverer"/>
|
||||
<adapter name="Ovm Discover" class="com.cloud.ovm.hypervisor.OvmDiscoverer" />
|
||||
</adapters>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class StopNetScalerVMCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the NetScaler vm")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.")
|
||||
private Boolean forced;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ListTungstenFabricTagCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.VM_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric vm")
|
||||
private String vmUuid;
|
||||
|
||||
@Parameter(name = ApiConstants.NIC_UUID, type = CommandType.STRING, description = "tthe uuid of Tungsten-Fabric nic")
|
||||
@Parameter(name = ApiConstants.NIC_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric nic")
|
||||
private String nicUuid;
|
||||
|
||||
@Parameter(name = ApiConstants.POLICY_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric policy")
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class ListElastistorVolumeResponse extends BaseResponse {
|
|||
private String compression;
|
||||
|
||||
@SerializedName("sync")
|
||||
@Param(description = "syncronization")
|
||||
@Param(description = "synchronization")
|
||||
private String sync;
|
||||
|
||||
public String getGraceAllowed() {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class LdapConfigurationResponse extends BaseResponse {
|
|||
private String hostname;
|
||||
|
||||
@SerializedName(ApiConstants.PORT)
|
||||
@Param(description = "port teh ldap server is running on")
|
||||
@Param(description = "port the ldap server is running on")
|
||||
private int port;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class LinkAccountToLdapResponse extends BaseResponse {
|
|||
private String ldapDomain;
|
||||
|
||||
@SerializedName(ApiConstants.TYPE)
|
||||
@Param(description = "type of the name in LDAP which is linke to the domain")
|
||||
@Param(description = "type of the name in LDAP which is linked to the domain")
|
||||
private String type;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT_TYPE)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class LinkDomainToLdapResponse extends BaseResponse {
|
|||
private String ldapDomain;
|
||||
|
||||
@SerializedName(ApiConstants.TYPE)
|
||||
@Param(description = "type of the name in LDAP which is linke to the domain")
|
||||
@Param(description = "type of the name in LDAP which is linked to the domain")
|
||||
private String type;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT_TYPE)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
|
|
@ -101,6 +102,11 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
|
|||
ctx.putContextParameters((Map<Object, Object>) gson.fromJson(contextDetails, objectMapType));
|
||||
}
|
||||
|
||||
String httpmethod = params.get(ApiConstants.HTTPMETHOD);
|
||||
if (httpmethod != null) {
|
||||
cmdObj.setHttpMethod(httpmethod);
|
||||
}
|
||||
|
||||
try {
|
||||
// dispatch could ultimately queue the job
|
||||
_dispatcher.dispatch(cmdObj, params, true);
|
||||
|
|
|
|||
|
|
@ -1104,7 +1104,7 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static GuestOS findGuestOSByDisplayName(String displayName) {
|
||||
return s_guestOSDao.listByDisplayName(displayName);
|
||||
return s_guestOSDao.findOneByDisplayName(displayName);
|
||||
}
|
||||
|
||||
public static HostVO findHostById(Long hostId) {
|
||||
|
|
@ -1283,6 +1283,9 @@ public class ApiDBUtils {
|
|||
// If this check is not passed, the hypervisor type will remain OVM.
|
||||
type = HypervisorType.KVM;
|
||||
break;
|
||||
} else if (pool.getHypervisor() == HypervisorType.Custom) {
|
||||
type = HypervisorType.Custom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
|
|
@ -371,6 +372,7 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.user.UserData;
|
||||
import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.user.dao.UserDataDao;
|
||||
import com.cloud.user.dao.UserStatisticsDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -463,6 +465,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
NetworkServiceMapDao ntwkSrvcDao;
|
||||
@Inject
|
||||
FirewallRulesDao firewallRulesDao;
|
||||
@Inject
|
||||
UserDataDao userDataDao;
|
||||
|
||||
@Override
|
||||
public UserResponse createUserResponse(User user) {
|
||||
|
|
@ -735,7 +739,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
if (vm != null) {
|
||||
vmSnapshotResponse.setVirtualMachineId(vm.getUuid());
|
||||
vmSnapshotResponse.setVirtualMachineName(StringUtils.isEmpty(vm.getDisplayName()) ? vm.getHostName() : vm.getDisplayName());
|
||||
vmSnapshotResponse.setHypervisor(vm.getHypervisorType());
|
||||
vmSnapshotResponse.setHypervisor(vm.getHypervisorType().getHypervisorDisplayName());
|
||||
DataCenterVO datacenter = ApiDBUtils.findZoneById(vm.getDataCenterId());
|
||||
if (datacenter != null) {
|
||||
vmSnapshotResponse.setZoneId(datacenter.getUuid());
|
||||
|
|
@ -1437,7 +1441,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
clusterResponse.setZoneId(dc.getUuid());
|
||||
clusterResponse.setZoneName(dc.getName());
|
||||
}
|
||||
clusterResponse.setHypervisorType(cluster.getHypervisorType().toString());
|
||||
clusterResponse.setHypervisorType(cluster.getHypervisorType().getHypervisorDisplayName());
|
||||
clusterResponse.setClusterType(cluster.getClusterType().toString());
|
||||
clusterResponse.setAllocationState(cluster.getAllocationState().toString());
|
||||
clusterResponse.setManagedState(cluster.getManagedState().toString());
|
||||
|
|
@ -1633,7 +1637,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
vmResponse.setTemplateName(template.getName());
|
||||
}
|
||||
vmResponse.setCreated(vm.getCreated());
|
||||
vmResponse.setHypervisor(vm.getHypervisorType().toString());
|
||||
vmResponse.setHypervisor(vm.getHypervisorType().getHypervisorDisplayName());
|
||||
|
||||
if (vm.getHostId() != null) {
|
||||
Host host = ApiDBUtils.findHostById(vm.getHostId());
|
||||
|
|
@ -2793,7 +2797,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
public HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities) {
|
||||
HypervisorCapabilitiesResponse hpvCapabilitiesResponse = new HypervisorCapabilitiesResponse();
|
||||
hpvCapabilitiesResponse.setId(hpvCapabilities.getUuid());
|
||||
hpvCapabilitiesResponse.setHypervisor(hpvCapabilities.getHypervisorType());
|
||||
hpvCapabilitiesResponse.setHypervisor(hpvCapabilities.getHypervisorType().getHypervisorDisplayName());
|
||||
hpvCapabilitiesResponse.setHypervisorVersion(hpvCapabilities.getHypervisorVersion());
|
||||
hpvCapabilitiesResponse.setIsSecurityGroupEnabled(hpvCapabilities.isSecurityGroupEnabled());
|
||||
hpvCapabilitiesResponse.setMaxGuestsLimit(hpvCapabilities.getMaxGuestsLimit());
|
||||
|
|
@ -3437,9 +3441,20 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
VMTemplateVO template = ApiDBUtils.findTemplateById(profile.getTemplateId());
|
||||
if (template != null) {
|
||||
response.setTemplateId(template.getUuid());
|
||||
if (template.getUserDataOverridePolicy() != null) {
|
||||
response.setUserDataPolicy(template.getUserDataOverridePolicy().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
response.setUserData(profile.getUserData());
|
||||
if (profile.getUserDataId() != null) {
|
||||
UserData userData = userDataDao.findById(profile.getUserDataId());
|
||||
if (userData != null) {
|
||||
response.setUserDataId(userData.getUuid());
|
||||
response.setUserDataName(userData.getName());
|
||||
}
|
||||
}
|
||||
response.setUserDataDetails(profile.getUserDataDetails());
|
||||
response.setOtherDeployParams(profile.getOtherDeployParamsList());
|
||||
response.setCounterParams(profile.getCounterParams());
|
||||
response.setExpungeVmGracePeriod(profile.getExpungeVmGracePeriod());
|
||||
|
|
@ -3677,6 +3692,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setDescription(guestOS.getDisplayName());
|
||||
response.setId(guestOS.getUuid());
|
||||
response.setIsUserDefined(String.valueOf(guestOS.getIsUserDefined()));
|
||||
response.setForDisplay(guestOS.getForDisplay());
|
||||
GuestOSCategoryVO category = ApiDBUtils.findGuestOsCategoryById(guestOS.getCategoryId());
|
||||
if (category != null) {
|
||||
response.setOsCategoryId(category.getUuid());
|
||||
|
|
@ -3691,7 +3707,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
public GuestOsMappingResponse createGuestOSMappingResponse(GuestOSHypervisor guestOSHypervisor) {
|
||||
GuestOsMappingResponse response = new GuestOsMappingResponse();
|
||||
response.setId(guestOSHypervisor.getUuid());
|
||||
response.setHypervisor(guestOSHypervisor.getHypervisorType());
|
||||
response.setHypervisor(Hypervisor.HypervisorType.getType(guestOSHypervisor.getHypervisorType()).getHypervisorDisplayName());
|
||||
response.setHypervisorVersion(guestOSHypervisor.getHypervisorVersion());
|
||||
response.setOsNameForHypervisor((guestOSHypervisor.getGuestOsName()));
|
||||
response.setIsUserDefined(Boolean.valueOf(guestOSHypervisor.getIsUserDefined()).toString());
|
||||
|
|
@ -4941,7 +4957,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setId(certificate.getUuid());
|
||||
response.setAlias(certificate.getAlias());
|
||||
handleCertificateResponse(certificate.getCertificate(), response);
|
||||
response.setHypervisor(certificate.getHypervisorType().name());
|
||||
response.setHypervisor(certificate.getHypervisorType().getHypervisorDisplayName());
|
||||
response.setObjectName("directdownloadcertificate");
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -740,6 +740,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
params.put("ctxStartEventId", String.valueOf(startEventId));
|
||||
params.put("cmdEventType", asyncCmd.getEventType().toString());
|
||||
params.put("ctxDetails", ApiGsonHelper.getBuilder().create().toJson(ctx.getContextParameters()));
|
||||
if (asyncCmd.getHttpMethod() != null) {
|
||||
params.put(ApiConstants.HTTPMETHOD, asyncCmd.getHttpMethod().toString());
|
||||
}
|
||||
|
||||
Long instanceId = (objectId == null) ? asyncCmd.getApiResourceId() : objectId;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class DefaultLoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthe
|
|||
@Parameter(name = ApiConstants.DOMAIN, type = CommandType.STRING, description = "Path of the domain that the user belongs to. Example: domain=/com/cloud/internal. If no domain is passed in, the ROOT (/) domain is assumed.")
|
||||
private String domain;
|
||||
|
||||
@Parameter(name = ApiConstants.DOMAIN__ID, type = CommandType.LONG, description = "The id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precendence")
|
||||
@Parameter(name = ApiConstants.DOMAIN__ID, type = CommandType.LONG, description = "The id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precedence.")
|
||||
private Long domainId;
|
||||
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -3968,7 +3968,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
@Override
|
||||
public ListResponse<TemplateResponse> listIsos(ListIsosCmd cmd) {
|
||||
Pair<List<TemplateJoinVO>, Integer> result = searchForIsosInternal(cmd);
|
||||
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
|
||||
ListResponse<TemplateResponse> response = new ListResponse<>();
|
||||
|
||||
ResponseView respView = ResponseView.Restricted;
|
||||
if (cmd instanceof ListIsosCmdByAdmin) {
|
||||
|
|
@ -3995,11 +3995,11 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
listAll = true;
|
||||
}
|
||||
|
||||
List<Long> permittedAccountIds = new ArrayList<Long>();
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
List<Long> permittedAccountIds = new ArrayList<>();
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, listAll, false);
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
List<Account> permittedAccounts = new ArrayList<Account>();
|
||||
List<Account> permittedAccounts = new ArrayList<>();
|
||||
for (Long accountId : permittedAccountIds) {
|
||||
permittedAccounts.add(_accountMgr.getAccount(accountId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -150,7 +149,7 @@ public class ViewResponseHelper {
|
|||
public static List<UserVmResponse> createUserVmResponse(ResponseView view, String objectName, Set<VMDetails> details, Boolean accumulateStats, Boolean showUserData,
|
||||
UserVmJoinVO... userVms) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
|
||||
LinkedHashMap<Long, UserVmResponse> vmDataList = new LinkedHashMap<>();
|
||||
// Initialise the vmdatalist with the input data
|
||||
|
||||
for (UserVmJoinVO userVm : userVms) {
|
||||
|
|
@ -169,7 +168,7 @@ public class ViewResponseHelper {
|
|||
|
||||
public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
|
||||
LinkedHashMap<Long, DomainRouterResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (DomainRouterJoinVO vr : routers) {
|
||||
DomainRouterResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -187,7 +186,7 @@ public class ViewResponseHelper {
|
|||
|
||||
public static List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
|
||||
LinkedHashMap<Long, SecurityGroupResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (SecurityGroupJoinVO vr : securityGroups) {
|
||||
SecurityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -205,7 +204,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<ProjectResponse> createProjectResponse(EnumSet<DomainDetails> details, ProjectJoinVO... projects) {
|
||||
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
|
||||
LinkedHashMap<Long, ProjectResponse> prjDataList = new LinkedHashMap<>();
|
||||
// Initialise the prjdatalist with the input data
|
||||
for (ProjectJoinVO p : projects) {
|
||||
ProjectResponse pData = prjDataList.get(p.getId());
|
||||
|
|
@ -247,7 +246,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<HostResponse> createHostResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
|
||||
Hashtable<Long, HostResponse> vrDataList = new Hashtable<Long, HostResponse>();
|
||||
LinkedHashMap<Long, HostResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (HostJoinVO vr : hosts) {
|
||||
HostResponse vrData = ApiDBUtils.newHostResponse(vr, details);
|
||||
|
|
@ -257,7 +256,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<HostForMigrationResponse> createHostForMigrationResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
|
||||
Hashtable<Long, HostForMigrationResponse> vrDataList = new Hashtable<Long, HostForMigrationResponse>();
|
||||
LinkedHashMap<Long, HostForMigrationResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (HostJoinVO vr : hosts) {
|
||||
HostForMigrationResponse vrData = ApiDBUtils.newHostForMigrationResponse(vr, details);
|
||||
|
|
@ -267,7 +266,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
|
||||
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
|
||||
LinkedHashMap<Long, VolumeResponse> vrDataList = new LinkedHashMap<>();
|
||||
DecimalFormat df = new DecimalFormat("0.0%");
|
||||
for (VolumeJoinVO vr : volumes) {
|
||||
VolumeResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -308,7 +307,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<StoragePoolResponse> createStoragePoolResponse(StoragePoolJoinVO... pools) {
|
||||
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
|
||||
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (StoragePoolJoinVO vr : pools) {
|
||||
StoragePoolResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -345,7 +344,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO... stores) {
|
||||
Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<Long, ImageStoreResponse>();
|
||||
LinkedHashMap<Long, ImageStoreResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (ImageStoreJoinVO vr : stores) {
|
||||
ImageStoreResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -362,7 +361,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
|
||||
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
|
||||
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (StoragePoolJoinVO vr : pools) {
|
||||
StoragePoolResponse vrData = vrDataList.get(vr.getId());
|
||||
|
|
@ -577,7 +576,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<TemplateResponse> createTemplateResponse(EnumSet<ApiConstants.DomainDetails> detailsView, ResponseView view, TemplateJoinVO... templates) {
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<String, TemplateResponse>();
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
|
||||
if (vrData == null) {
|
||||
|
|
@ -594,7 +593,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<TemplateResponse> createTemplateUpdateResponse(ResponseView view, TemplateJoinVO... templates) {
|
||||
Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
|
||||
LinkedHashMap<Long, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getId());
|
||||
if (vrData == null) {
|
||||
|
|
@ -610,7 +609,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<TemplateResponse> createIsoResponse(ResponseView view, TemplateJoinVO... templates) {
|
||||
Hashtable<String, TemplateResponse> vrDataList = new Hashtable<String, TemplateResponse>();
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
|
||||
if (vrData == null) {
|
||||
|
|
@ -626,7 +625,7 @@ public class ViewResponseHelper {
|
|||
}
|
||||
|
||||
public static List<AffinityGroupResponse> createAffinityGroupResponses(List<AffinityGroupJoinVO> groups) {
|
||||
Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<Long, AffinityGroupResponse>();
|
||||
LinkedHashMap<Long, AffinityGroupResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (AffinityGroupJoinVO vr : groups) {
|
||||
AffinityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
if (vrData == null) {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
|
|||
}
|
||||
|
||||
if (router.getHypervisorType() != null) {
|
||||
routerResponse.setHypervisor(router.getHypervisorType().toString());
|
||||
routerResponse.setHypervisor(router.getHypervisorType().getHypervisorDisplayName());
|
||||
}
|
||||
routerResponse.setHasAnnotation(annotationDao.hasAnnotations(router.getUuid(), AnnotationService.EntityType.VR.name(),
|
||||
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
|
||||
|
|
|
|||
|
|
@ -125,7 +125,10 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||
hostResponse.setCpuNumber(host.getCpus());
|
||||
hostResponse.setZoneId(host.getZoneUuid());
|
||||
hostResponse.setDisconnectedOn(host.getDisconnectedOn());
|
||||
hostResponse.setHypervisor(host.getHypervisorType());
|
||||
if (host.getHypervisorType() != null) {
|
||||
String hypervisorType = host.getHypervisorType().getHypervisorDisplayName();
|
||||
hostResponse.setHypervisor(hypervisorType);
|
||||
}
|
||||
hostResponse.setHostType(host.getType());
|
||||
hostResponse.setLastPinged(new Date(host.getLastPinged()));
|
||||
Long mshostId = host.getManagementServerId();
|
||||
|
|
@ -239,7 +242,8 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||
hostResponse.setUefiCapabilty(new Boolean(false));
|
||||
}
|
||||
}
|
||||
if (details.contains(HostDetails.all) && host.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
|
||||
if (details.contains(HostDetails.all) && (host.getHypervisorType() == Hypervisor.HypervisorType.KVM ||
|
||||
host.getHypervisorType() == Hypervisor.HypervisorType.Custom)) {
|
||||
//only kvm has the requirement to return host details
|
||||
try {
|
||||
hostResponse.setDetails(hostDetails);
|
||||
|
|
@ -303,7 +307,7 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||
hostResponse.setCpuNumber(host.getCpus());
|
||||
hostResponse.setZoneId(host.getZoneUuid());
|
||||
hostResponse.setDisconnectedOn(host.getDisconnectedOn());
|
||||
hostResponse.setHypervisor(host.getHypervisorType());
|
||||
hostResponse.setHypervisor(host.getHypervisorType().getHypervisorDisplayName());
|
||||
hostResponse.setHostType(host.getType());
|
||||
hostResponse.setLastPinged(new Date(host.getLastPinged()));
|
||||
hostResponse.setManagementServerId(host.getManagementServerId());
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
|||
poolResponse.setScope(pool.getScope().toString());
|
||||
}
|
||||
if (pool.getHypervisor() != null) {
|
||||
poolResponse.setHypervisor(pool.getHypervisor().toString());
|
||||
poolResponse.setHypervisor(pool.getHypervisor().getHypervisorDisplayName());
|
||||
}
|
||||
|
||||
StoragePoolDetailVO poolType = storagePoolDetailsDao.findDetail(pool.getId(), "pool_type");
|
||||
|
|
@ -201,7 +201,7 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
|||
poolResponse.setCreated(pool.getCreated());
|
||||
poolResponse.setScope(pool.getScope().toString());
|
||||
if (pool.getHypervisor() != null) {
|
||||
poolResponse.setHypervisor(pool.getHypervisor().toString());
|
||||
poolResponse.setHypervisor(pool.getHypervisor().getHypervisorDisplayName());
|
||||
}
|
||||
|
||||
long allocatedSize = pool.getUsedCapacity();
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||
templateResponse.setTemplateType(template.getTemplateType().toString());
|
||||
}
|
||||
|
||||
templateResponse.setHypervisor(template.getHypervisorType().toString());
|
||||
templateResponse.setHypervisor(template.getHypervisorType().getHypervisorDisplayName());
|
||||
|
||||
templateResponse.setOsTypeId(template.getGuestOSUuid());
|
||||
templateResponse.setOsTypeName(template.getGuestOSName());
|
||||
|
|
@ -330,7 +330,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||
response.setOsTypeId(result.getGuestOSUuid());
|
||||
response.setOsTypeName(result.getGuestOSName());
|
||||
response.setBootable(result.isBootable());
|
||||
response.setHypervisor(result.getHypervisorType().toString());
|
||||
response.setHypervisor(result.getHypervisorType().getHypervisorDisplayName());
|
||||
response.setDynamicallyScalable(result.isDynamicallyScalable());
|
||||
|
||||
// populate owner.
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
UserVmResponse userVmResponse = new UserVmResponse();
|
||||
|
||||
if (userVm.getHypervisorType() != null) {
|
||||
userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
|
||||
userVmResponse.setHypervisor(userVm.getHypervisorType().getHypervisorDisplayName());
|
||||
}
|
||||
userVmResponse.setId(userVm.getUuid());
|
||||
userVmResponse.setName(userVm.getName());
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
|
|
@ -147,8 +148,10 @@ public class VolumeJoinDaoImpl extends GenericDaoBaseWithTagInformation<VolumeJo
|
|||
volResponse.setSize(volume.getVolumeStoreSize());
|
||||
volResponse.setCreated(volume.getCreatedOnStore());
|
||||
|
||||
if (view == ResponseView.Full)
|
||||
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()).toString());
|
||||
if (view == ResponseView.Full) {
|
||||
Hypervisor.HypervisorType hypervisorTypeFromFormat = ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat());
|
||||
volResponse.setHypervisor(hypervisorTypeFromFormat.getHypervisorDisplayName());
|
||||
}
|
||||
if (volume.getDownloadState() != Status.DOWNLOADED) {
|
||||
String volumeStatus = "Processing";
|
||||
if (volume.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
|
||||
|
|
@ -209,9 +212,10 @@ public class VolumeJoinDaoImpl extends GenericDaoBaseWithTagInformation<VolumeJo
|
|||
if (view == ResponseView.Full) {
|
||||
if (volume.getState() != Volume.State.UploadOp) {
|
||||
if (volume.getHypervisorType() != null) {
|
||||
volResponse.setHypervisor(volume.getHypervisorType().toString());
|
||||
volResponse.setHypervisor(volume.getHypervisorType().getHypervisorDisplayName());
|
||||
} else {
|
||||
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()).toString());
|
||||
Hypervisor.HypervisorType hypervisorTypeFromFormat = ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat());
|
||||
volResponse.setHypervisor(hypervisorTypeFromFormat.getHypervisorDisplayName());
|
||||
}
|
||||
}
|
||||
Long poolId = volume.getPoolId();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
|
|
@ -773,6 +774,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
final TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.start();
|
||||
|
||||
String previousValue = _configDao.getValue(name);
|
||||
if (!_configDao.update(name, category, value)) {
|
||||
s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value);
|
||||
throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
|
||||
|
|
@ -853,6 +855,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
} catch (final Throwable e) {
|
||||
throw new CloudRuntimeException("Failed to clean up download URLs in template_store_ref or volume_store_ref due to exception ", e);
|
||||
}
|
||||
} else if (HypervisorGuru.HypervisorCustomDisplayName.key().equals(name)) {
|
||||
updateCustomDisplayNameOnHypervisorsList(previousValue, value);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
|
@ -860,6 +864,20 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
return _configDao.getValue(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the 'hypervisor.list' value to match the new custom hypervisor name set as newValue if the previous value was set
|
||||
*/
|
||||
private void updateCustomDisplayNameOnHypervisorsList(String previousValue, String newValue) {
|
||||
String hypervisorListConfigName = Config.HypervisorList.key();
|
||||
String hypervisors = _configDao.getValue(hypervisorListConfigName);
|
||||
if (Arrays.asList(hypervisors.split(",")).contains(previousValue)) {
|
||||
hypervisors = hypervisors.replace(previousValue, newValue);
|
||||
s_logger.info(String.format("Updating the hypervisor list configuration '%s' " +
|
||||
"to match the new custom hypervisor display name", hypervisorListConfigName));
|
||||
_configDao.update(hypervisorListConfigName, hypervisors);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, eventDescription = "updating configuration")
|
||||
public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidParameterValueException {
|
||||
|
|
|
|||
|
|
@ -360,7 +360,10 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
|||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor, VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor };
|
||||
return new ConfigKey<?>[] {VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor,
|
||||
VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor,
|
||||
HypervisorCustomDisplayName
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.discoverer;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.kvm.discoverer.LibvirtServerDiscoverer;
|
||||
|
||||
public class CustomServerDiscoverer extends LibvirtServerDiscoverer {
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisorType() {
|
||||
return Hypervisor.HypervisorType.Custom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPatchPath() {
|
||||
return "scripts/vm/hypervisor/kvm/";
|
||||
}
|
||||
}
|
||||
|
|
@ -532,7 +532,6 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
long zoneId = cmd.getZoneId();
|
||||
long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
Long autoscaleUserId = cmd.getAutoscaleUserId();
|
||||
String userData = cmd.getUserData();
|
||||
|
||||
DataCenter zone = entityMgr.findById(DataCenter.class, zoneId);
|
||||
|
||||
|
|
@ -545,6 +544,11 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
throw new InvalidParameterValueException("Unable to find service offering by id");
|
||||
}
|
||||
|
||||
VirtualMachineTemplate template = entityMgr.findById(VirtualMachineTemplate.class, cmd.getTemplateId());
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("Unable to find template by id " + cmd.getTemplateId());
|
||||
}
|
||||
|
||||
// validations
|
||||
HashMap<String, String> deployParams = cmd.getDeployParamMap();
|
||||
/*
|
||||
|
|
@ -562,9 +566,23 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
profileVO.setDisplay(cmd.getDisplay());
|
||||
}
|
||||
|
||||
String userData = cmd.getUserData();
|
||||
Long userDataId = cmd.getUserDataId();
|
||||
String userDataDetails = null;
|
||||
if (MapUtils.isNotEmpty(cmd.getUserDataDetails())) {
|
||||
userDataDetails = cmd.getUserDataDetails().toString();
|
||||
}
|
||||
userData = userVmMgr.finalizeUserData(userData, userDataId, template);
|
||||
userData = userVmMgr.validateUserData(userData, cmd.getHttpMethod());
|
||||
if (userData != null) {
|
||||
profileVO.setUserData(userData);
|
||||
}
|
||||
if (userDataId != null) {
|
||||
profileVO.setUserDataId(userDataId);
|
||||
}
|
||||
if (userDataDetails != null) {
|
||||
profileVO.setUserDataDetails(userDataDetails);
|
||||
}
|
||||
|
||||
profileVO = checkValidityAndPersist(profileVO, true);
|
||||
s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId());
|
||||
|
|
@ -582,12 +600,19 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
Map<String, HashMap<String, String>> otherDeployParams = cmd.getOtherDeployParams();
|
||||
Map counterParamList = cmd.getCounterParamList();
|
||||
String userData = cmd.getUserData();
|
||||
Long userDataId = cmd.getUserDataId();
|
||||
String userDataDetails = null;
|
||||
if (MapUtils.isNotEmpty(cmd.getUserDataDetails())) {
|
||||
userDataDetails = cmd.getUserDataDetails().toString();
|
||||
}
|
||||
boolean userdataUpdate = userData != null || userDataId != null || MapUtils.isNotEmpty(cmd.getUserDataDetails());
|
||||
|
||||
Integer expungeVmGracePeriod = cmd.getExpungeVmGracePeriod();
|
||||
|
||||
AutoScaleVmProfileVO vmProfile = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, autoScaleVmProfileDao);
|
||||
|
||||
boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null || otherDeployParams != null || expungeVmGracePeriod != null || userData != null);
|
||||
boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null
|
||||
|| otherDeployParams != null || expungeVmGracePeriod != null || userdataUpdate);
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
vmProfile.setServiceOfferingId(serviceOfferingId);
|
||||
|
|
@ -609,10 +634,6 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
vmProfile.setCounterParamsForUpdate(counterParamList);
|
||||
}
|
||||
|
||||
if (userData != null) {
|
||||
vmProfile.setUserData(userData);
|
||||
}
|
||||
|
||||
if (expungeVmGracePeriod != null) {
|
||||
vmProfile.setExpungeVmGracePeriod(expungeVmGracePeriod);
|
||||
}
|
||||
|
|
@ -625,6 +646,18 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
vmProfile.setDisplay(cmd.getDisplay());
|
||||
}
|
||||
|
||||
if (userdataUpdate) {
|
||||
if (templateId == null) {
|
||||
templateId = vmProfile.getTemplateId();
|
||||
}
|
||||
VirtualMachineTemplate template = entityMgr.findByIdIncludingRemoved(VirtualMachineTemplate.class, templateId);
|
||||
userData = userVmMgr.finalizeUserData(userData, userDataId, template);
|
||||
userData = userVmMgr.validateUserData(userData, cmd.getHttpMethod());
|
||||
vmProfile.setUserDataId(userDataId);
|
||||
vmProfile.setUserData(userData);
|
||||
vmProfile.setUserDataDetails(userDataDetails);
|
||||
}
|
||||
|
||||
List<AutoScaleVmGroupVO> vmGroupList = autoScaleVmGroupDao.listByAll(null, profileId);
|
||||
for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) {
|
||||
if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State.DISABLED)) {
|
||||
|
|
@ -1740,6 +1773,8 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
}
|
||||
|
||||
String userData = profileVo.getUserData();
|
||||
Long userDataId = profileVo.getUserDataId();
|
||||
String userDataDetails = profileVo.getUserDataDetails();
|
||||
|
||||
UserVm vm = null;
|
||||
IpAddresses addrs = new IpAddresses(null, null);
|
||||
|
|
@ -1763,20 +1798,20 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
|
|||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
vm = userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, null, owner, vmHostName,
|
||||
vmHostName, diskOfferingId, dataDiskSize, null,
|
||||
hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs,
|
||||
hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs,
|
||||
null, null, true, null, affinityGroupIdList, customParameters, null, null, null,
|
||||
null, true, overrideDiskOfferingId);
|
||||
} else {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
vm = userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, networkIds, null,
|
||||
owner, vmHostName,vmHostName, diskOfferingId, dataDiskSize, null,
|
||||
hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs,
|
||||
hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs,
|
||||
null, null, true, null, affinityGroupIdList, customParameters, null, null, null,
|
||||
null, true, overrideDiskOfferingId, null);
|
||||
} else {
|
||||
vm = userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, networkIds, owner, vmHostName, vmHostName,
|
||||
diskOfferingId, dataDiskSize, null,
|
||||
hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs,
|
||||
hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs,
|
||||
null, addrs, true, null, affinityGroupIdList, customParameters, null, null, null,
|
||||
null, true, null, overrideDiskOfferingId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1071,7 +1071,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
SecurityGroupRulesCmd cmd = generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), vm.getPrivateMacAddress(), vm.getId(),
|
||||
SecurityGroupRulesCmd cmd = generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress(), vm.getId(),
|
||||
generateRulesetSignature(ingressRules, egressRules), seqnum, ingressRules, egressRules, nicSecIps);
|
||||
Commands cmds = new Commands(cmd);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl {
|
|||
return;
|
||||
}
|
||||
SecurityGroupRulesCmd cmd =
|
||||
generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), vm.getPrivateMacAddress(), vm.getId(), null, work.getLogsequenceNumber(),
|
||||
generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress(), vm.getId(), null, work.getLogsequenceNumber(),
|
||||
ingressRules, egressRules, nicSecIps);
|
||||
cmd.setMsId(_serverId);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import com.cloud.exception.StorageUnavailableException;
|
|||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import org.apache.cloudstack.alert.AlertService;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
|
|
@ -652,7 +653,9 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
}
|
||||
}
|
||||
|
||||
return discoverHostsFull(dcId, podId, clusterId, clusterName, url, username, password, cmd.getHypervisor(), hostTags, cmd.getFullUrlParams(), false);
|
||||
String hypervisorType = cmd.getHypervisor().equalsIgnoreCase(HypervisorGuru.HypervisorCustomDisplayName.value()) ?
|
||||
"Custom" : cmd.getHypervisor();
|
||||
return discoverHostsFull(dcId, podId, clusterId, clusterName, url, username, password, hypervisorType, hostTags, cmd.getFullUrlParams(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -773,7 +773,6 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
|
|||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
|
|
@ -1264,7 +1263,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
}
|
||||
|
||||
if (hypervisorType != null) {
|
||||
sc.setParameters("hypervisorType", hypervisorType);
|
||||
String hypervisorStr = (String) hypervisorType;
|
||||
String hypervisorSearch = HypervisorType.getType(hypervisorStr).toString();
|
||||
sc.setParameters("hypervisorType", hypervisorSearch);
|
||||
}
|
||||
|
||||
if (clusterType != null) {
|
||||
|
|
@ -2623,43 +2624,15 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
@Override
|
||||
public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(final ListGuestOsCmd cmd) {
|
||||
final Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
final Long id = cmd.getId();
|
||||
final Long osCategoryId = cmd.getOsCategoryId();
|
||||
final String description = cmd.getDescription();
|
||||
final String keyword = cmd.getKeyword();
|
||||
final Long startIndex = cmd.getStartIndex();
|
||||
final Long pageSize = cmd.getPageSizeVal();
|
||||
Boolean forDisplay = cmd.getDisplay();
|
||||
|
||||
final SearchCriteria<GuestOSVO> sc = _guestOSDao.createSearchCriteria();
|
||||
|
||||
if (id != null) {
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
} else {
|
||||
GenericSearchBuilder<GuestOSVO, Long> sb = _guestOSDao.createSearchBuilder(Long.class);
|
||||
sb.select(null, SearchCriteria.Func.MAX, sb.entity().getId());
|
||||
sb.groupBy(sb.entity().getCategoryId(), sb.entity().getDisplayName());
|
||||
sb.done();
|
||||
|
||||
final SearchCriteria<Long> scGuestOs = sb.create();
|
||||
final List<Long> guestOSVOList = _guestOSDao.customSearch(scGuestOs, null);
|
||||
if (CollectionUtils.isNotEmpty(guestOSVOList)) {
|
||||
sc.addAnd("id", SearchCriteria.Op.IN, guestOSVOList.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (osCategoryId != null) {
|
||||
sc.addAnd("categoryId", SearchCriteria.Op.EQ, osCategoryId);
|
||||
}
|
||||
|
||||
if (description != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + description + "%");
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
}
|
||||
|
||||
final Pair<List<GuestOSVO>, Integer> result = _guestOSDao.searchAndCount(sc, searchFilter);
|
||||
return new Pair<List<? extends GuestOS>, Integer>(result.first(), result.second());
|
||||
return _guestOSDao.listGuestOSByCriteria(startIndex, pageSize, id, osCategoryId, description, keyword, forDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2878,18 +2851,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
guestOsVo.setDisplayName(displayName);
|
||||
guestOsVo.setName(name);
|
||||
guestOsVo.setIsUserDefined(true);
|
||||
guestOsVo.setDisplay(cmd.getForDisplay() == null ? true : cmd.getForDisplay());
|
||||
final GuestOS guestOsPersisted = _guestOSDao.persist(guestOsVo);
|
||||
|
||||
if (cmd.getDetails() != null && !cmd.getDetails().isEmpty()) {
|
||||
Map<String, String> detailsMap = cmd.getDetails();
|
||||
for (Object key : detailsMap.keySet()) {
|
||||
_guestOsDetailsDao.addDetail(guestOsPersisted.getId(), (String)key, detailsMap.get(key), false);
|
||||
}
|
||||
}
|
||||
persistGuestOsDetails(cmd.getDetails(), guestOsPersisted.getId());
|
||||
|
||||
return guestOsPersisted;
|
||||
}
|
||||
|
||||
private void persistGuestOsDetails(Map<String, String> details, long guestOsPersistedId) {
|
||||
for (Object key : details.keySet()) {
|
||||
_guestOsDetailsDao.addDetail(guestOsPersistedId, (String)key, details.get(key), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_ADD, eventDescription = "Adding a new guest OS type", async = true)
|
||||
public GuestOS getAddedGuestOs(final Long guestOsId) {
|
||||
|
|
@ -2913,12 +2888,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
throw new InvalidParameterValueException("Unable to modify system defined guest OS");
|
||||
}
|
||||
|
||||
if (cmd.getDetails() != null && !cmd.getDetails().isEmpty()) {
|
||||
Map<String, String> detailsMap = cmd.getDetails();
|
||||
for (Object key : detailsMap.keySet()) {
|
||||
_guestOsDetailsDao.addDetail(id, (String)key, detailsMap.get(key), false);
|
||||
}
|
||||
}
|
||||
persistGuestOsDetails(cmd.getDetails(), id);
|
||||
|
||||
//Check if update is needed
|
||||
if (displayName.equals(guestOsHandle.getDisplayName())) {
|
||||
|
|
@ -2932,6 +2902,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
}
|
||||
final GuestOSVO guestOs = _guestOSDao.createForUpdate(id);
|
||||
guestOs.setDisplayName(displayName);
|
||||
if (cmd.getForDisplay() != null) {
|
||||
guestOs.setDisplay(cmd.getForDisplay());
|
||||
}
|
||||
if (_guestOSDao.update(id, guestOs)) {
|
||||
return _guestOSDao.findById(id);
|
||||
} else {
|
||||
|
|
@ -4470,7 +4443,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
} else {
|
||||
final List<ClusterVO> clustersForZone = _clusterDao.listByZoneId(zoneId);
|
||||
for (final ClusterVO cluster : clustersForZone) {
|
||||
result.add(cluster.getHypervisorType().toString());
|
||||
result.add(cluster.getHypervisorType().getHypervisorDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,20 +148,21 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate on random running KVM host that URL is reachable
|
||||
* Validate on random running host that URL is reachable
|
||||
* @param url url
|
||||
*/
|
||||
private Long performDirectDownloadUrlValidation(final String format, final String url, final List<Long> zoneIds) {
|
||||
private Long performDirectDownloadUrlValidation(final String format, final Hypervisor.HypervisorType hypervisor,
|
||||
final String url, final List<Long> zoneIds) {
|
||||
HostVO host = null;
|
||||
if (zoneIds != null && !zoneIds.isEmpty()) {
|
||||
for (Long zoneId : zoneIds) {
|
||||
host = resourceManager.findOneRandomRunningHostByHypervisor(Hypervisor.HypervisorType.KVM, zoneId);
|
||||
host = resourceManager.findOneRandomRunningHostByHypervisor(hypervisor, zoneId);
|
||||
if (host != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
host = resourceManager.findOneRandomRunningHostByHypervisor(Hypervisor.HypervisorType.KVM, null);
|
||||
host = resourceManager.findOneRandomRunningHostByHypervisor(hypervisor, null);
|
||||
}
|
||||
|
||||
if (host == null) {
|
||||
|
|
@ -198,7 +199,8 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
zoneIds = new ArrayList<>();
|
||||
zoneIds.add(cmd.getZoneId());
|
||||
}
|
||||
Long templateSize = performDirectDownloadUrlValidation(ImageFormat.ISO.getFileExtension(), url, zoneIds);
|
||||
Long templateSize = performDirectDownloadUrlValidation(ImageFormat.ISO.getFileExtension(),
|
||||
Hypervisor.HypervisorType.KVM, url, zoneIds);
|
||||
profile.setSize(templateSize);
|
||||
}
|
||||
profile.setUrl(url);
|
||||
|
|
@ -221,9 +223,11 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
TemplateProfile profile = super.prepare(cmd);
|
||||
String url = profile.getUrl();
|
||||
UriUtils.validateUrl(cmd.getFormat(), url, cmd.isDirectDownload());
|
||||
Hypervisor.HypervisorType hypervisor = Hypervisor.HypervisorType.getType(cmd.getHypervisor());
|
||||
if (cmd.isDirectDownload()) {
|
||||
DigestHelper.validateChecksumString(cmd.getChecksum());
|
||||
Long templateSize = performDirectDownloadUrlValidation(cmd.getFormat(), url, cmd.getZoneIds());
|
||||
Long templateSize = performDirectDownloadUrlValidation(cmd.getFormat(),
|
||||
hypervisor, url, cmd.getZoneIds());
|
||||
profile.setSize(templateSize);
|
||||
}
|
||||
profile.setUrl(url);
|
||||
|
|
|
|||
|
|
@ -309,8 +309,12 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||
if (type == HypervisorType.BareMetal) {
|
||||
adapter = AdapterBase.getAdapterByName(_adapters, TemplateAdapterType.BareMetal.getName());
|
||||
} else {
|
||||
// see HypervisorTemplateAdapter
|
||||
adapter = AdapterBase.getAdapterByName(_adapters, TemplateAdapterType.Hypervisor.getName());
|
||||
// Get template adapter according to hypervisor
|
||||
adapter = AdapterBase.getAdapterByName(_adapters, type.name());
|
||||
// Otherwise, default to generic hypervisor template adapter
|
||||
if (adapter == null) {
|
||||
adapter = AdapterBase.getAdapterByName(_adapters, TemplateAdapterType.Hypervisor.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (adapter == null) {
|
||||
|
|
@ -1215,7 +1219,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||
tmplt = _tmplFactory.getReadyBypassedTemplateOnPrimaryStore(isoId, poolId, hostId);
|
||||
bypassed = true;
|
||||
} else {
|
||||
tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId);
|
||||
tmplt = _tmplFactory.getReadyTemplateOnImageStore(isoId, dcId);
|
||||
}
|
||||
|
||||
if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) {
|
||||
|
|
|
|||
|
|
@ -3327,7 +3327,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
protected UserTwoFactorAuthenticationSetupResponse disableTwoFactorAuthentication(Long userId, Account caller, Account owner) {
|
||||
UserVO userVO = null;
|
||||
if (userId != null) {
|
||||
userVO = validateUser(userId, caller.getDomainId());
|
||||
userVO = validateUser(userId);
|
||||
owner = _accountService.getActiveAccountById(userVO.getAccountId());
|
||||
} else {
|
||||
userId = CallContext.current().getCallingUserId();
|
||||
|
|
@ -3349,16 +3349,13 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
return response;
|
||||
}
|
||||
|
||||
private UserVO validateUser(Long userId, Long domainId) {
|
||||
private UserVO validateUser(Long userId) {
|
||||
UserVO user = null;
|
||||
if (userId != null) {
|
||||
user = _userDao.findById(userId);
|
||||
if (user == null) {
|
||||
throw new InvalidParameterValueException("Invalid user ID provided");
|
||||
}
|
||||
if (_accountDao.findById(user.getAccountId()).getDomainId() != domainId) {
|
||||
throw new InvalidParameterValueException("User doesn't belong to the specified account or domain");
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ public interface UserVmManager extends UserVmService {
|
|||
"Destroys the VM's root volume when the VM is destroyed.",
|
||||
true, ConfigKey.Scope.Domain);
|
||||
|
||||
static final int MAX_USER_DATA_LENGTH_BYTES = 2048;
|
||||
|
||||
public static final String CKS_NODE = "cksnode";
|
||||
|
||||
/**
|
||||
|
|
@ -90,6 +92,10 @@ public interface UserVmManager extends UserVmService {
|
|||
|
||||
void removeInstanceFromInstanceGroup(long vmId);
|
||||
|
||||
String finalizeUserData(String userData, Long userDataId, VirtualMachineTemplate template);
|
||||
|
||||
String validateUserData(String userData, HTTPMethod httpmethod);
|
||||
|
||||
boolean isVMUsingLocalStorage(VMInstanceVO vm);
|
||||
|
||||
boolean expunge(UserVmVO vm);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue