Skip to content

Commit c1a02e1

Browse files
committed
Merge remote-tracking branch 'origin/4.15'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents d763169 + d6a7427 commit c1a02e1

File tree

115 files changed

+399
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+399
-120
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiServerService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ public ResponseObject loginUser(HttpSession session, String username, String pas
4242
public String handleRequest(Map<String, Object[]> params, String responseType, StringBuilder auditTrailSb) throws ServerApiException;
4343

4444
public Class<?> getCmdClass(String cmdName);
45-
46-
public boolean isValidApiName(String apiName);
4745
}

api/src/main/java/org/apache/cloudstack/api/command/admin/acl/ImportRoleCmd.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ public List<Map<String, Object>> getRules() {
9494
if (Strings.isNullOrEmpty(rule)) {
9595
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty rule provided in rules param");
9696
}
97-
if (!rule.contains("*") && !_apiServer.isValidApiName(rule)) {
98-
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid api name: " + rule + " provided in rules param");
99-
}
10097
ruleDetails.put(ApiConstants.RULE, new Rule(rule));
10198

10299
String permission = detail.get(ApiConstants.PERMISSION);

engine/storage/src/main/java/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public DataStore attachCluster(DataStore store) {
173173

174174
public DataStore attachZone(DataStore store) {
175175
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
176+
storageMgr.createCapacityEntry(pool.getId());
176177
pool.setScope(ScopeType.ZONE);
177178
pool.setStatus(StoragePoolStatus.Up);
178179
this.dataStoreDao.update(pool.getId(), pool);
@@ -181,6 +182,7 @@ public DataStore attachZone(DataStore store) {
181182

182183
public DataStore attachZone(DataStore store, HypervisorType hypervisor) {
183184
StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
185+
storageMgr.createCapacityEntry(pool.getId());
184186
pool.setScope(ScopeType.ZONE);
185187
pool.setHypervisor(hypervisor);
186188
pool.setStatus(StoragePoolStatus.Up);

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,13 @@ protected StartAnswer execute(StartCommand cmd) {
20722072
// Setup ROOT/DATA disk devices
20732073
//
20742074
for (DiskTO vol : sortedDisks) {
2075-
if (vol.getType() == Volume.Type.ISO || deployAsIs && vol.getType() == Volume.Type.ROOT) {
2075+
if (vol.getType() == Volume.Type.ISO) {
2076+
continue;
2077+
}
2078+
2079+
if (deployAsIs && vol.getType() == Volume.Type.ROOT) {
2080+
rootDiskTO = vol;
2081+
resizeRootDiskOnVMStart(vmMo, rootDiskTO, hyperHost, context);
20762082
continue;
20772083
}
20782084

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.cloudstack.api.BaseCmd;
3232
import org.apache.cloudstack.api.command.user.firewall.CreateFirewallRuleCmd;
3333
import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
34+
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
3435
import org.apache.commons.codec.binary.Base64;
3536
import org.apache.commons.collections.CollectionUtils;
3637
import org.apache.log4j.Level;
@@ -70,6 +71,10 @@
7071
import com.cloud.network.rules.dao.PortForwardingRulesDao;
7172
import com.cloud.offering.ServiceOffering;
7273
import com.cloud.resource.ResourceManager;
74+
import com.cloud.storage.Volume;
75+
import com.cloud.storage.VolumeApiService;
76+
import com.cloud.storage.VolumeVO;
77+
import com.cloud.storage.dao.VolumeDao;
7378
import com.cloud.user.Account;
7479
import com.cloud.user.SSHKeyPairVO;
7580
import com.cloud.uservm.UserVm;
@@ -118,6 +123,10 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu
118123
protected VMInstanceDao vmInstanceDao;
119124
@Inject
120125
protected UserVmManager userVmManager;
126+
@Inject
127+
protected VolumeApiService volumeService;
128+
@Inject
129+
protected VolumeDao volumeDao;
121130

122131
protected String kubernetesClusterNodeNamePrefix;
123132

@@ -268,13 +277,37 @@ protected DeployDestination plan() throws InsufficientServerCapacityException {
268277
return plan(kubernetesCluster.getTotalNodeCount(), zone, offering);
269278
}
270279

280+
protected void resizeNodeVolume(final UserVm vm) throws ManagementServerException {
281+
try {
282+
if (vm.getHypervisorType() == Hypervisor.HypervisorType.VMware && templateDao.findById(vm.getTemplateId()).isDeployAsIs()) {
283+
List<VolumeVO> vmVols = volumeDao.findByInstance(vm.getId());
284+
for (VolumeVO volumeVO : vmVols) {
285+
if (volumeVO.getVolumeType() == Volume.Type.ROOT) {
286+
ResizeVolumeCmd resizeVolumeCmd = new ResizeVolumeCmd();
287+
resizeVolumeCmd = ComponentContext.inject(resizeVolumeCmd);
288+
Field f = resizeVolumeCmd.getClass().getDeclaredField("size");
289+
Field f1 = resizeVolumeCmd.getClass().getDeclaredField("id");
290+
f.setAccessible(true);
291+
f1.setAccessible(true);
292+
f1.set(resizeVolumeCmd, volumeVO.getId());
293+
f.set(resizeVolumeCmd, kubernetesCluster.getNodeRootDiskSize());
294+
volumeService.resizeVolume(resizeVolumeCmd);
295+
}
296+
}
297+
}
298+
} catch (IllegalAccessException | NoSuchFieldException e) {
299+
throw new ManagementServerException(String.format("Failed to resize volume of VM in the Kubernetes cluster : %s", kubernetesCluster.getName()), e);
300+
}
301+
}
302+
271303
protected void startKubernetesVM(final UserVm vm) throws ManagementServerException {
272304
try {
273305
StartVMCmd startVm = new StartVMCmd();
274306
startVm = ComponentContext.inject(startVm);
275307
Field f = startVm.getClass().getDeclaredField("id");
276308
f.setAccessible(true);
277309
f.set(startVm, vm.getId());
310+
resizeNodeVolume(vm);
278311
userVmService.startVirtualMachine(startVm);
279312
if (LOGGER.isInfoEnabled()) {
280313
LOGGER.info(String.format("Started VM : %s in the Kubernetes cluster : %s", vm.getDisplayName(), kubernetesCluster.getName()));
@@ -296,6 +329,7 @@ protected List<UserVm> provisionKubernetesClusterNodeVms(final long nodeCount, f
296329
for (int i = offset + 1; i <= nodeCount; i++) {
297330
UserVm vm = createKubernetesNode(publicIpAddress, i);
298331
addKubernetesClusterVm(kubernetesCluster.getId(), vm.getId());
332+
resizeNodeVolume(vm);
299333
startKubernetesVM(vm);
300334
vm = userVmDao.findById(vm.getId());
301335
if (vm == null) {

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ private UserVm provisionKubernetesClusterMasterVm(final Network network, final S
277277
UserVm k8sMasterVM = null;
278278
k8sMasterVM = createKubernetesMaster(network, publicIpAddress);
279279
addKubernetesClusterVm(kubernetesCluster.getId(), k8sMasterVM.getId());
280+
resizeNodeVolume(k8sMasterVM);
280281
startKubernetesVM(k8sMasterVM);
281282
k8sMasterVM = userVmDao.findById(k8sMasterVM.getId());
282283
if (k8sMasterVM == null) {
@@ -296,6 +297,7 @@ private List<UserVm> provisionKubernetesClusterAdditionalMasterVms(final String
296297
UserVm vm = null;
297298
vm = createKubernetesAdditionalMaster(publicIpAddress, i);
298299
addKubernetesClusterVm(kubernetesCluster.getId(), vm.getId());
300+
resizeNodeVolume(vm);
299301
startKubernetesVM(vm);
300302
vm = userVmDao.findById(vm.getId());
301303
if (vm == null) {

server/src/main/java/com/cloud/api/ApiServer.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,17 +1208,6 @@ else if (cmdList.size() == 1)
12081208
}
12091209
}
12101210

1211-
@Override
1212-
public boolean isValidApiName(String apiName) {
1213-
if (apiName == null || apiName.isEmpty())
1214-
return false;
1215-
1216-
if (!s_apiNameCmdClassMap.containsKey(apiName))
1217-
return false;
1218-
1219-
return true;
1220-
}
1221-
12221211
// FIXME: rather than isError, we might was to pass in the status code to give more flexibility
12231212
private void writeResponse(final HttpResponse resp, final String responseText, final int statusCode, final String responseType, final String reasonPhrase) {
12241213
try {

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,15 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
962962
}
963963

964964
// if we are to use the existing disk offering
965+
ImageFormat format = null;
965966
if (newDiskOffering == null) {
966-
if (volume.getVolumeType().equals(Volume.Type.ROOT) && diskOffering.getDiskSize() > 0) {
967+
Long templateId = volume.getTemplateId();
968+
if (templateId != null) {
969+
VMTemplateVO template = _templateDao.findById(templateId);
970+
format = template.getFormat();
971+
}
972+
973+
if (volume.getVolumeType().equals(Volume.Type.ROOT) && diskOffering.getDiskSize() > 0 && format != null && format != ImageFormat.ISO) {
967974
throw new InvalidParameterValueException(
968975
"Failed to resize Root volume. The service offering of this Volume has been configured with a root disk size; "
969976
+ "on such case a Root Volume can only be resized when changing to another Service Offering with a Root disk size. "

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145
import com.cloud.agent.manager.Commands;
146146
import com.cloud.alert.AlertManager;
147147
import com.cloud.api.ApiDBUtils;
148+
import com.cloud.api.query.dao.ServiceOfferingJoinDao;
149+
import com.cloud.api.query.vo.ServiceOfferingJoinVO;
148150
import com.cloud.capacity.Capacity;
149151
import com.cloud.capacity.CapacityManager;
150152
import com.cloud.configuration.Config;
@@ -512,7 +514,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
512514
@Inject
513515
private UserVmDeployAsIsDetailsDao userVmDeployAsIsDetailsDao;
514516
@Inject
515-
private StorageManager _storageManager;
517+
private StorageManager storageManager;
518+
@Inject
519+
private ServiceOfferingJoinDao serviceOfferingJoinDao;
516520

517521
private ScheduledExecutorService _executor = null;
518522
private ScheduledExecutorService _vmIpFetchExecutor = null;
@@ -2051,7 +2055,7 @@ public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, Str
20512055
if (poolType == StoragePoolType.PowerFlex) {
20522056
// Get volume stats from the pool directly instead of sending cmd to host
20532057
// Added support for ScaleIO/PowerFlex pool only
2054-
answer = _storageManager.getVolumeStats(storagePool, cmd);
2058+
answer = storageManager.getVolumeStats(storagePool, cmd);
20552059
} else {
20562060
if (timeout > 0) {
20572061
cmd.setWait(timeout/1000);
@@ -5313,9 +5317,21 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
53135317
throw new InvalidParameterValueException("Unable to use template " + templateId);
53145318
}
53155319

5316-
// Bootmode and boottype are not supported on VMWare dpeloy-as-is templates (since 4.15)
5317-
if (template.isDeployAsIs() && (cmd.getBootMode() != null || cmd.getBootType() != null)) {
5318-
throw new InvalidParameterValueException("Boot type and boot mode are not supported on VMware, as we honour what is defined in the template.");
5320+
ServiceOfferingJoinVO svcOffering = serviceOfferingJoinDao.findById(serviceOfferingId);
5321+
5322+
if (template.isDeployAsIs()) {
5323+
if (svcOffering != null && svcOffering.getRootDiskSize() != null && svcOffering.getRootDiskSize() > 0) {
5324+
throw new InvalidParameterValueException("Failed to deploy Virtual Machine as a service offering with root disk size specified cannot be used with a deploy as-is template");
5325+
}
5326+
5327+
if (cmd.getDetails().get("rootdisksize") != null) {
5328+
throw new InvalidParameterValueException("Overriding root disk size isn't supported for VMs deployed from defploy as-is templates");
5329+
}
5330+
5331+
// Bootmode and boottype are not supported on VMWare dpeloy-as-is templates (since 4.15)
5332+
if ((cmd.getBootMode() != null || cmd.getBootType() != null)) {
5333+
throw new InvalidParameterValueException("Boot type and boot mode are not supported on VMware, as we honour what is defined in the template.");
5334+
}
53195335
}
53205336

53215337
Long diskOfferingId = cmd.getDiskOfferingId();
@@ -6349,7 +6365,7 @@ public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinatio
63496365
HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
63506366
if (hypervisorType.equals(HypervisorType.VMware)) {
63516367
try {
6352-
boolean isStoragePoolStoragepolicyComplaince = _storageManager.isStoragePoolComplaintWithStoragePolicy(Arrays.asList(volume), pool);
6368+
boolean isStoragePoolStoragepolicyComplaince = storageManager.isStoragePoolComplaintWithStoragePolicy(Arrays.asList(volume), pool);
63536369
if (!isStoragePoolStoragepolicyComplaince) {
63546370
throw new CloudRuntimeException(String.format("Storage pool %s is not storage policy compliance with the volume %s", pool.getUuid(), volume.getUuid()));
63556371
}

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,7 @@
26922692
"message.delete.vpn.customer.gateway": "Please confirm that you want to delete this VPN Customer Gateway",
26932693
"message.delete.vpn.gateway": "Please confirm that you want to delete this VPN Gateway",
26942694
"message.deleting.vm": "Deleting VM",
2695+
"message.deployasis": "Selected template is Deploy As-Is i.e., the VM is deployed by importing an OVA with vApps directly into vCenter. Root disk(s) resize is allowed only on stopped VMs for such templates.",
26952696
"message.desc.add.new.lb.sticky.rule": "Add new LB sticky rule",
26962697
"message.desc.advanced.zone": "For more sophisticated network topologies. This network model provides the most flexibility in defining guest networks and providing custom network offerings such as firewall, VPN, or load balancer support.",
26972698
"message.desc.basic.zone": "Provide a single network where each VM instance is assigned an IP directly from the network. Guest isolation can be provided through layer-3 means such as security groups (IP address source filtering).",

0 commit comments

Comments
 (0)