Skip to content

Commit 5c4e161

Browse files
DaanHooglandnvazquez
authored andcommitted
Add the option to filter by host when retrieving of unregistered VMs (apache#9925)
Co-authored-by: Nicolas Vazquez <[email protected]>
1 parent c4a266a commit 5c4e161

File tree

27 files changed

+1014
-904
lines changed

27 files changed

+1014
-904
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class ApiConstants {
6363
public static final String BASE64_IMAGE = "base64image";
6464
public static final String BGP_PEERS = "bgppeers";
6565
public static final String BGP_PEER_IDS = "bgppeerids";
66+
public static final String BATCH_SIZE = "batchsize";
6667
public static final String BITS = "bits";
6768
public static final String BOOTABLE = "bootable";
6869
public static final String BIND_DN = "binddn";
@@ -492,11 +493,12 @@ public class ApiConstants {
492493
public static final String STATE = "state";
493494
public static final String STATS = "stats";
494495
public static final String STATUS = "status";
495-
public static final String STORAGE_TYPE = "storagetype";
496-
public static final String STORAGE_POLICY = "storagepolicy";
497-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
498496
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
499497
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
498+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
499+
public static final String STORAGE_POLICY = "storagepolicy";
500+
public static final String STORAGE_POOL = "storagepool";
501+
public static final String STORAGE_TYPE = "storagetype";
500502
public static final String SUBNET = "subnet";
501503
public static final String OWNER = "owner";
502504
public static final String SWAP_OWNER = "swapowner";
@@ -1297,6 +1299,14 @@ public class ApiConstants {
12971299
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
12981300
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
12991301
"value will be applied.";
1302+
1303+
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1304+
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1305+
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
1306+
1307+
public static final String PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1308+
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1309+
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
13001310

13011311
public static final String DR_CLUSTER_TYPE = "drclustertype";
13021312
public static final String DR_CLUSTER_URL = "drclusterurl";
@@ -1321,6 +1331,8 @@ public class ApiConstants {
13211331
public static final String MIRRORING_AGENT_STATUS = "mirroringagentstatus";
13221332
public static final String DISASTER_RECOVERY_CLUSTER_VM_LIST = "disasterrecoveryclustervmlist";
13231333

1334+
public static final String VMWARE_DC = "vmwaredc";
1335+
13241336
/**
13251337
* This enum specifies IO Drivers, each option controls specific policies on I/O.
13261338
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
@@ -1343,14 +1355,6 @@ public String toString() {
13431355
}
13441356
}
13451357

1346-
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1347-
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1348-
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
1349-
1350-
public static final String PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1351-
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1352-
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
1353-
13541358
public enum BootType {
13551359
UEFI, BIOS;
13561360

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
152152
@Deprecated
153153
@SerializedName("memoryallocated")
154154
@Param(description = "the amount of the host's memory currently allocated")
155-
private long memoryAllocated;
155+
private Long memoryAllocated;
156156

157157
@SerializedName("memoryallocatedpercentage")
158158
@Param(description = "the amount of the host's memory currently allocated in percentage")
@@ -419,7 +419,7 @@ public void setMemWithOverprovisioning(String memWithOverprovisioning){
419419
this.memWithOverprovisioning=memWithOverprovisioning;
420420
}
421421

422-
public void setMemoryAllocated(long memoryAllocated) {
422+
public void setMemoryAllocated(Long memoryAllocated) {
423423
this.memoryAllocated = memoryAllocated;
424424
}
425425

@@ -707,8 +707,8 @@ public Long getMemoryTotal() {
707707
return memoryTotal;
708708
}
709709

710-
public long getMemoryAllocated() {
711-
return memoryAllocated;
710+
public Long getMemoryAllocated() {
711+
return memoryAllocated == null ? 0 : memoryAllocated;
712712
}
713713

714714
public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) {

plugins/acl/dynamic-role-based/src/main/java/org/apache/cloudstack/acl/DynamicRoleBasedAPIAccessChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class DynamicRoleBasedAPIAccessChecker extends AdapterBase implements API
4747
private RoleService roleService;
4848

4949
private List<PluggableService> services;
50-
private Map<RoleType, Set<String>> annotationRoleBasedApisMap = new HashMap<RoleType, Set<String>>();
50+
private Map<RoleType, Set<String>> annotationRoleBasedApisMap = new HashMap<>();
5151

5252
private LazyCache<Long, Account> accountCache;
5353
private LazyCache<Long, Pair<Role, List<RolePermission>>> rolePermissionsCache;
@@ -56,7 +56,7 @@ public class DynamicRoleBasedAPIAccessChecker extends AdapterBase implements API
5656
protected DynamicRoleBasedAPIAccessChecker() {
5757
super();
5858
for (RoleType roleType : RoleType.values()) {
59-
annotationRoleBasedApisMap.put(roleType, new HashSet<String>());
59+
annotationRoleBasedApisMap.put(roleType, new HashSet<>());
6060
}
6161
}
6262

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareDatacenterService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222
import com.cloud.dc.VsphereStoragePolicy;
2323
import com.cloud.exception.DiscoveryException;
2424
import com.cloud.exception.ResourceInUseException;
25+
import com.cloud.hypervisor.vmware.mo.HostMO;
2526
import com.cloud.storage.StoragePool;
27+
import com.cloud.utils.Pair;
2628
import com.cloud.utils.component.PluggableService;
2729
import com.cloud.utils.exception.CloudRuntimeException;
2830
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
2931
import org.apache.cloudstack.api.command.admin.zone.ImportVsphereStoragePoliciesCmd;
3032
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcVmsCmd;
33+
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcHostsCmd;
3134
import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd;
3235
import org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePoliciesCmd;
3336
import org.apache.cloudstack.api.command.admin.zone.ListVsphereStoragePolicyCompatiblePoolsCmd;
@@ -53,5 +56,7 @@ public interface VmwareDatacenterService extends PluggableService {
5356

5457
List<StoragePool> listVsphereStoragePolicyCompatibleStoragePools(ListVsphereStoragePolicyCompatiblePoolsCmd cmd);
5558

56-
List<UnmanagedInstanceTO> listVMsInDatacenter(ListVmwareDcVmsCmd cmd);
59+
List<HostMO> listHostsInDatacenter(ListVmwareDcHostsCmd cmd);
60+
61+
Pair<String, List<UnmanagedInstanceTO>> listVMsInDatacenter(ListVmwareDcVmsCmd cmd);
5762
}

0 commit comments

Comments
 (0)