Skip to content

Commit 4aae051

Browse files
committed
CLOUDSTACK-9333: Exclude clusters for OVF operations
1 parent 419f8fb commit 4aae051

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

engine/components-api/src/com/cloud/capacity/CapacityManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public interface CapacityManager {
5353
"0.85",
5454
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.",
5555
true, ConfigKey.Scope.Zone);
56+
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
57+
new ConfigKey<Boolean>(
58+
Boolean.class,
59+
"cluster.storage.operations.exclude",
60+
"Advanced",
61+
"false",
62+
"Exclude cluster from storage operations",
63+
true,
64+
ConfigKey.Scope.Cluster,
65+
null);
5666

5767
public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);
5868

engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.cloudstack.storage.LocalHostEndpoint;
4545
import org.apache.cloudstack.storage.RemoteHostEndPoint;
4646

47+
import com.cloud.capacity.CapacityManager;
4748
import com.cloud.host.Host;
4849
import com.cloud.host.HostVO;
4950
import com.cloud.host.Status;
@@ -64,9 +65,13 @@ public class DefaultEndPointSelector implements EndPointSelector {
6465
private static final Logger s_logger = Logger.getLogger(DefaultEndPointSelector.class);
6566
@Inject
6667
HostDao hostDao;
67-
private final String findOneHostOnPrimaryStorage =
68-
"select h.id from host h, storage_pool_host_ref s where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and"
69-
+ " h.id = s.host_id and s.pool_id = ? ";
68+
private final String findOneHostOnPrimaryStorage = "select t.id from "
69+
+ "(select h.id, cd.value "
70+
+ "from host h join storage_pool_host_ref s on h.id = s.host_id "
71+
+ "join cluster c on c.id=h.cluster_id "
72+
+ "left join cluster_details cd on c.id=cd.cluster_id and cd.name='" + CapacityManager.StorageOperationsExcludeCluster.key() + "' "
73+
+ "where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and s.pool_id = ? ";
74+
7075
private String findOneHypervisorHostInScope = "select h.id from host h where h.status = 'Up' and h.hypervisor_type is not null ";
7176

7277
protected boolean moveBetweenPrimaryImage(DataStore srcStore, DataStore destStore) {
@@ -115,6 +120,7 @@ protected EndPoint findEndPointInScope(Scope scope, String sqlBase, Long poolId)
115120
sbuilder.append(scope.getScopeId());
116121
}
117122
// TODO: order by rand() is slow if there are lot of hosts
123+
sbuilder.append(") t where t.value<>'true' or t.value is null"); //Added for exclude cluster's subquery
118124
sbuilder.append(" ORDER by rand() limit 1");
119125
String sql = sbuilder.toString();
120126
HostVO host = null;

server/src/com/cloud/capacity/CapacityManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,6 @@ public String getConfigComponentName() {
10821082
@Override
10831083
public ConfigKey<?>[] getConfigKeys() {
10841084
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor,
1085-
StorageAllocatedCapacityDisableThreshold};
1085+
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster};
10861086
}
10871087
}

setup/db/db/schema-481to490.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,6 @@ VIEW `user_vm_view` AS
410410
AND (`custom_speed`.`name` = 'CpuSpeed'))))
411411
LEFT JOIN `user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `vm_instance`.`id`)
412412
AND (`custom_ram_size`.`name` = 'memory'))));
413+
414+
-- Add cluster.storage.operations.exclude property
415+
INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `description`, `default_value`, `updated`, `scope`, `is_dynamic`) VALUES ('Advanced', 'DEFAULT', 'CapacityManager', 'cluster.storage.operations.exclude', 'Exclude cluster from storage operations', 'false', now(), 'Cluster', '1');

0 commit comments

Comments
 (0)