Skip to content

Commit

Permalink
Disallow importing to disbled clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh92 committed Nov 11, 2024
1 parent 0bed37b commit 872ecae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,10 @@ private UserVmResponse baseImportInstance(ImportUnmanagedInstanceCmd cmd) {
Long clusterId = cmd.getClusterId();
Cluster cluster = basicAccessChecks(clusterId);

if (!cluster.getAllocationState().equals(Cluster.AllocationState.Enabled)) {
throw new InvalidParameterValueException(String.format("Cluster [%s] is not enabled.", cluster));
}

final Account caller = CallContext.current().getCallingAccount();
final DataCenter zone = dataCenterDao.findById(cluster.getDataCenterId());
final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
Expand Down
3 changes: 2 additions & 1 deletion ui/src/views/tools/ManageInstances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ export default {
options: {
zoneid: _.get(this.zone, 'id'),
podid: this.podId,
hypervisor: this.destinationHypervisor
hypervisor: this.destinationHypervisor,
allocationstate: 'Enabled'
},
field: 'clusterid'
},
Expand Down

0 comments on commit 872ecae

Please sign in to comment.