Merge remote-tracking branch 'origin/4.14'

This commit is contained in:
Rohit Yadav 2020-06-25 10:48:02 +05:30
commit 3ede1eaa49
13 changed files with 137 additions and 6 deletions

View File

@ -353,6 +353,7 @@ public class ApiConstants {
public static final String TARGET_IQN = "targetiqn";
public static final String TEMPLATE_FILTER = "templatefilter";
public static final String TEMPLATE_ID = "templateid";
public static final String TEMPLATE_NAME = "templatename";
public static final String ISO_ID = "isoid";
public static final String TIMEOUT = "timeout";
public static final String TIMEZONE = "timezone";
@ -601,8 +602,10 @@ public class ApiConstants {
public static final String END_POINT = "endpoint";
public static final String REGION_ID = "regionid";
public static final String VPC_OFF_ID = "vpcofferingid";
public static final String VPC_OFF_NAME = "vpcofferingname";
public static final String NETWORK = "network";
public static final String VPC_ID = "vpcid";
public static final String VPC_NAME = "vpcname";
public static final String GATEWAY_ID = "gatewayid";
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
public static final String RESOURCE_IDS = "resourceids";

View File

@ -77,6 +77,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@Param(description = "the Pod ID for the router")
private String podId;
@SerializedName(ApiConstants.POD_NAME)
@Param(description = "the Pod name for the router", since = "4.13.2")
private String podName;
@SerializedName(ApiConstants.HOST_ID)
@Param(description = "the host ID for the router")
private String hostId;
@ -145,6 +149,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@Param(description = "the template ID for the router")
private String templateId;
@SerializedName(ApiConstants.TEMPLATE_NAME)
@Param(description = "the template name for the router", since = "4.13.2")
private String templateName;
@SerializedName(ApiConstants.CREATED)
@Param(description = "the date and time the router was created")
private Date created;
@ -278,6 +286,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
this.podId = podId;
}
public void setPodName(String podName) {
this.podName = podName;
}
public void setHostId(String hostId) {
this.hostId = hostId;
}
@ -330,6 +342,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
this.templateId = templateId;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public void setCreated(Date created) {
this.created = created;
}

View File

@ -136,8 +136,13 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
private String purpose;
@SerializedName(ApiConstants.VPC_ID)
@Param(description = "VPC the ip belongs to")
@Param(description = "VPC id the ip belongs to")
private String vpcId;
@SerializedName(ApiConstants.VPC_NAME)
@Param(description = "VPC name the ip belongs to", since = "4.13.2")
private String vpcName;
@SerializedName(ApiConstants.TAGS)
@Param(description = "the list of resource tags associated with ip address", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
@ -277,6 +282,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.vpcId = vpcId;
}
public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}
public void setTags(List<ResourceTagResponse> tags) {
this.tags = tags;
}

View File

@ -58,9 +58,13 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
private String broadcastUri;
@SerializedName(ApiConstants.VPC_ID)
@Param(description = "VPC the private gateaway belongs to")
@Param(description = "VPC id the private gateway belongs to")
private String vpcId;
@SerializedName(ApiConstants.VPC_NAME)
@Param(description = "VPC name the private gateway belongs to", since = "4.13.2")
private String vpcName;
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
@Param(description = "the physical network id")
private String physicalNetworkId;
@ -130,6 +134,10 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
this.vpcId = vpcId;
}
public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}
public void setAddress(String address) {
this.address = address;
}

View File

@ -42,6 +42,10 @@ public class Site2SiteVpnGatewayResponse extends BaseResponse implements Control
@Param(description = "the vpc id of this gateway")
private String vpcId;
@SerializedName(ApiConstants.VPC_NAME)
@Param(description = "the vpc name of this gateway", since = "4.13.2")
private String vpcName;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the owner")
private String accountName;
@ -82,6 +86,10 @@ public class Site2SiteVpnGatewayResponse extends BaseResponse implements Control
this.vpcId = vpcId;
}
public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}
public void setRemoved(Date removed) {
this.removed = removed;
}

View File

@ -78,6 +78,10 @@ public class SystemVmResponse extends BaseResponse {
@Param(description = "the Pod ID for the system VM")
private String podId;
@SerializedName("podname")
@Param(description = "the Pod name for the system VM", since = "4.13.2")
private String podName;
@SerializedName("hostid")
@Param(description = "the host ID for the system VM")
private String hostId;
@ -130,6 +134,10 @@ public class SystemVmResponse extends BaseResponse {
@Param(description = "the template ID for the system VM")
private String templateId;
@SerializedName("templatename")
@Param(description = "the template name for the system VM", since = "4.13.2")
private String templateName;
@SerializedName("created")
@Param(description = "the date and time the system VM was created")
private Date created;
@ -243,10 +251,18 @@ public class SystemVmResponse extends BaseResponse {
return podId;
}
public String getPodName() {
return podName;
}
public void setPodId(String podId) {
this.podId = podId;
}
public void setPodName(String podName) {
this.podName = podName;
}
public String getHostId() {
return hostId;
}
@ -323,10 +339,18 @@ public class SystemVmResponse extends BaseResponse {
return templateId;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public Date getCreated() {
return created;
}

View File

@ -298,6 +298,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
@Param(description = "OS type id of the vm", since = "4.4")
private String osTypeId;
@SerializedName(ApiConstants.OS_DISPLAY_NAME)
@Param(description = "OS name of the vm", since = "4.13.2")
private String osDisplayName;
@SerializedName(ApiConstants.BOOT_MODE)
@Param(description = "Guest vm Boot Mode")
private String bootMode;
@ -854,6 +858,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
this.osTypeId = osTypeId;
}
public void setOsDisplayName(String osDisplayName) {
this.osDisplayName = osDisplayName;
}
public Set<Long> getTagIds() {
return tagIds;
}
@ -882,6 +890,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
return osTypeId;
}
public String getOsDisplayName() {
return osDisplayName;
}
public String getBootType() { return bootType; }
public void setBootType(String bootType) { this.bootType = bootType; }
@ -889,5 +901,4 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
public String getBootMode() { return bootMode; }
public void setBootMode(String bootMode) { this.bootMode = bootMode; }
}

View File

@ -67,6 +67,10 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
@Param(description = "vpc offering id the VPC is created from")
private String vpcOfferingId;
@SerializedName(ApiConstants.VPC_OFF_NAME)
@Param(description = "vpc offering name the VPC is created from", since = "4.13.2")
private String vpcOfferingName;
@SerializedName(ApiConstants.CREATED)
@Param(description = "the date this VPC was created")
private Date created;
@ -184,6 +188,10 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
this.vpcOfferingId = vpcOfferingId;
}
public void setVpcOfferingName(final String vpcOfferingName) {
this.vpcOfferingName = vpcOfferingName;
}
public List<NetworkResponse> getNetworks() {
return networks;
}

View File

@ -875,6 +875,7 @@ public class ApiResponseHelper implements ResponseGenerator {
Vpc vpc = ApiDBUtils.findVpcById(ipAddr.getVpcId());
if (vpc != null) {
ipResponse.setVpcId(vpc.getUuid());
ipResponse.setVpcName(vpc.getName());
}
}
@ -1378,11 +1379,13 @@ public class ApiResponseHelper implements ResponseGenerator {
HostPodVO pod = ApiDBUtils.findPodById(vm.getPodIdToDeployIn());
if (pod != null) {
vmResponse.setPodId(pod.getUuid());
vmResponse.setPodName(pod.getName());
}
}
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
if (template != null) {
vmResponse.setTemplateId(template.getUuid());
vmResponse.setTemplateName(template.getName());
}
vmResponse.setCreated(vm.getCreated());
@ -2901,6 +2904,7 @@ public class ApiResponseHelper implements ResponseGenerator {
VpcOffering voff = ApiDBUtils.findVpcOfferingById(vpc.getVpcOfferingId());
if (voff != null) {
response.setVpcOfferingId(voff.getUuid());
response.setVpcOfferingName(voff.getName());
}
response.setCidr(vpc.getCidr());
response.setRestartRequired(vpc.isRestartRequired());
@ -2973,6 +2977,7 @@ public class ApiResponseHelper implements ResponseGenerator {
if (result.getVpcId() != null) {
Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
response.setVpcId(vpc.getUuid());
response.setVpcName(vpc.getName());
}
DataCenter zone = ApiDBUtils.findZoneById(result.getZoneId());
@ -3163,6 +3168,7 @@ public class ApiResponseHelper implements ResponseGenerator {
Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
if (vpc != null) {
response.setVpcId(vpc.getUuid());
response.setVpcName(vpc.getName());
}
response.setRemoved(result.getRemoved());
response.setForDisplay(result.isDisplay());

View File

@ -30,11 +30,14 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.utils.CloudStackVersion;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.query.vo.DomainRouterJoinVO;
import com.cloud.dc.HostPodVO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.storage.VMTemplateVO;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.utils.db.GenericDaoBase;
@ -46,7 +49,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
@Inject
private ConfigurationDao _configDao;
private ConfigurationDao _configDao;
@Inject
public AccountManager _accountMgr;
@ -74,6 +77,10 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
routerResponse.setZoneId(router.getDataCenterUuid());
routerResponse.setName(router.getName());
routerResponse.setTemplateId(router.getTemplateUuid());
VMTemplateVO template = ApiDBUtils.findTemplateById(router.getTemplateId());
if (template != null) {
routerResponse.setTemplateName(template.getName());
}
routerResponse.setCreated(router.getCreated());
routerResponse.setState(router.getState());
routerResponse.setIsRedundantRouter(router.isRedundantRouter());
@ -98,6 +105,10 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
routerResponse.setHypervisor(router.getHypervisorType().toString());
}
routerResponse.setPodId(router.getPodUuid());
HostPodVO pod = ApiDBUtils.findPodById(router.getPodId());
if (pod != null) {
routerResponse.setPodName(pod.getName());
}
long nic_id = router.getNicId();
if (nic_id > 0) {
TrafficType ty = router.getTrafficType();

View File

@ -47,6 +47,7 @@ import com.cloud.api.ApiResponseHelper;
import com.cloud.api.query.vo.UserVmJoinVO;
import com.cloud.gpu.GPU;
import com.cloud.service.ServiceOfferingDetailsVO;
import com.cloud.storage.GuestOS;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.User;
@ -68,7 +69,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
@Inject
private ConfigurationDao _configDao;
private ConfigurationDao _configDao;
@Inject
public AccountManager _accountMgr;
@Inject
@ -205,6 +206,10 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
userVmResponse.setPublicIp(userVm.getPublicIpAddress());
userVmResponse.setKeyPairName(userVm.getKeypairName());
userVmResponse.setOsTypeId(userVm.getGuestOsUuid());
GuestOS guestOS = ApiDBUtils.findGuestOSById(userVm.getGuestOsId());
if (guestOS != null) {
userVmResponse.setOsDisplayName(guestOS.getDisplayName());
}
if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
// stats calculation

View File

@ -278,6 +278,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualMachine> {
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
private static final String CONNECTIVITY_TEST = "connectivity.test";
private static final String BACKUP_ROUTER_EXCLUDED_TESTS = "gateways_check.py";
@Inject private EntityManager _entityMgr;
@Inject private DataCenterDao _dcDao;
@ -1632,7 +1633,11 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ENABLED, RouterHealthChecksEnabled.value().toString());
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_BASIC_INTERVAL, RouterHealthChecksBasicInterval.value().toString());
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ADVANCED_INTERVAL, RouterHealthChecksAdvancedInterval.value().toString());
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, RouterHealthChecksToExclude.valueIn(router.getDataCenterId()));
String excludedTests = RouterHealthChecksToExclude.valueIn(router.getDataCenterId());
if (router.getIsRedundantRouter() && RedundantState.BACKUP.equals(router.getRedundantState())) {
excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
}
command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
command.setHealthChecksConfig(getRouterHealthChecksConfig(router));
command.setReconfigureAfterUpdate(reconfigure);
command.setDeleteFromProcessedCache(deleteFromProcessedCache); // As part of updating

View File

@ -109,11 +109,13 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.gpu.GPU;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorCapabilitiesVO;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.org.Grouping;
import com.cloud.resource.ResourceState;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ResourceTag;
import com.cloud.server.TaggedResourceService;
@ -1190,6 +1192,21 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
if (currentSize != newSize && _volsDao.getHypervisorType(volume.getId()) == HypervisorType.XenServer && !userVm.getState().equals(State.Stopped)) {
throw new InvalidParameterValueException(errorMsg);
}
/* Do not resize volume of running vm on KVM host if host is not Up or not Enabled */
if (currentSize != newSize && userVm.getState() == State.Running && userVm.getHypervisorType() == HypervisorType.KVM) {
if (userVm.getHostId() == null) {
throw new InvalidParameterValueException("Cannot find the hostId of running vm " + userVm.getUuid());
}
HostVO host = _hostDao.findById(userVm.getHostId());
if (host == null) {
throw new InvalidParameterValueException("The KVM host where vm is running does not exist");
} else if (host.getStatus() != Status.Up) {
throw new InvalidParameterValueException("The KVM host where vm is running is not Up");
} else if (host.getResourceState() != ResourceState.Enabled) {
throw new InvalidParameterValueException("The KVM host where vm is running is not Enabled");
}
}
}
ResizeVolumePayload payload = new ResizeVolumePayload(newSize, newMinIops, newMaxIops, newHypervisorSnapshotReserve, shrinkOk, instanceName, hosts, isManaged);