Skip to content

Commit 56082f4

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 4fe1c52 + e7a55a7 commit 56082f4

50 files changed

Lines changed: 879 additions & 316 deletions

File tree

Some content is hidden

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

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ protected void setupStartupCommand(final StartupCommand startup) {
613613
}
614614

615615
protected String getAgentArch() {
616-
String arch = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("arch"), 1000);
616+
String arch = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("arch"), 2000);
617617
logger.debug("Arch for agent: {} found: {}", _name, arch);
618618
return arch;
619619
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
import com.cloud.user.UserData;
2423
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
2524
import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd;
2625
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
@@ -72,6 +71,7 @@
7271
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
7372
import org.apache.cloudstack.config.Configuration;
7473
import org.apache.cloudstack.config.ConfigurationGroup;
74+
import org.apache.cloudstack.framework.config.ConfigKey;
7575

7676
import com.cloud.alert.Alert;
7777
import com.cloud.capacity.Capacity;
@@ -91,6 +91,7 @@
9191
import com.cloud.storage.GuestOsCategory;
9292
import com.cloud.storage.StoragePool;
9393
import com.cloud.user.SSHKeyPair;
94+
import com.cloud.user.UserData;
9495
import com.cloud.utils.Pair;
9596
import com.cloud.utils.Ternary;
9697
import com.cloud.vm.InstanceGroup;
@@ -104,6 +105,14 @@
104105
public interface ManagementService {
105106
static final String Name = "management-server";
106107

108+
ConfigKey<Boolean> JsInterpretationEnabled = new ConfigKey<>("Hidden"
109+
, Boolean.class
110+
, "js.interpretation.enabled"
111+
, "false"
112+
, "Enable/Disable all JavaScript interpretation related functionalities to create or update Javascript rules."
113+
, false
114+
, ConfigKey.Scope.Global);
115+
107116
/**
108117
* returns the a map of the names/values in the configuration table
109118
*
@@ -509,4 +518,6 @@ VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableE
509518

510519
boolean removeManagementServer(RemoveManagementServerCmd cmd);
511520

521+
void checkJsInterpretationAllowedIfNeededForParameterValue(String paramName, boolean paramValue);
522+
512523
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
public interface ResourceManagerUtil {
2020
long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType);
21+
long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType, boolean checkAccess);
2122
String getUuid(String resourceId, ResourceTag.ResourceObjectType resourceType);
2223
ResourceTag.ResourceObjectType getResourceType(String resourceTypeStr);
2324
void checkResourceAccessible(Long accountId, Long domainId, String exceptionMessage);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ public class ApiConstants {
535535
public static final String SHOW_CAPACITIES = "showcapacities";
536536
public static final String SHOW_REMOVED = "showremoved";
537537
public static final String SHOW_RESOURCE_ICON = "showicon";
538-
public static final String SHOW_COMPLETED = "showcompleted";
539538
public static final String SHOW_INACTIVE = "showinactive";
540539
public static final String SHOW_UNIQUE = "showunique";
541540
public static final String SIGNATURE = "signature";
@@ -585,6 +584,7 @@ public class ApiConstants {
585584
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
586585
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
587586
public static final String TARGET_IQN = "targetiqn";
587+
public static final String TASKS_FILTER = "tasksfilter";
588588
public static final String TEMPLATE_FILTER = "templatefilter";
589589
public static final String TEMPLATE_ID = "templateid";
590590
public static final String TEMPLATE_IDS = "templateids";

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ListImportVMTasksCmd.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,8 @@ public class ListImportVMTasksCmd extends BaseListCmd {
7575
description = "Conversion host of the importing task")
7676
private Long convertHostId;
7777

78-
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "Whether to list all import tasks.")
79-
private boolean listAll = false;
80-
81-
@Parameter(name = ApiConstants.SHOW_COMPLETED, type = CommandType.BOOLEAN, description = "Whether to list completed tasks.")
82-
private boolean showCompleted = false;
78+
@Parameter(name = ApiConstants.TASKS_FILTER, type = CommandType.STRING, description = "Filter tasks by state, valid options are: All, Running, Completed, Failed")
79+
private String tasksFilter;
8380

8481
public Long getZoneId() {
8582
return zoneId;
@@ -97,12 +94,8 @@ public Long getConvertHostId() {
9794
return convertHostId;
9895
}
9996

100-
public boolean isListAll() {
101-
return listAll;
102-
}
103-
104-
public boolean isShowCompleted() {
105-
return showCompleted;
97+
public String getTasksFilter() {
98+
return tasksFilter;
10699
}
107100

108101
@Override

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public class ImportVMTaskResponse extends BaseResponse {
5555
@Param(description = "the display name of the importing VM")
5656
private String displayName;
5757

58+
@SerializedName(ApiConstants.STATE)
59+
@Param(description = "the state of the importing VM task")
60+
private String state;
61+
5862
@SerializedName(ApiConstants.VCENTER)
5963
@Param(description = "the vcenter name of the importing VM task")
6064
private String vcenter;
@@ -242,4 +246,12 @@ public Date getLastUpdated() {
242246
public void setLastUpdated(Date lastUpdated) {
243247
this.lastUpdated = lastUpdated;
244248
}
249+
250+
public String getState() {
251+
return state;
252+
}
253+
254+
public void setState(String state) {
255+
this.state = state;
256+
}
245257
}

api/src/main/java/org/apache/cloudstack/vm/ImportVmTask.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323

2424
public interface ImportVmTask extends Identity, InternalIdentity {
2525
enum Step {
26-
Prepare, CloningInstance, ConvertingInstance, Importing, Cleaning, Completed
26+
Prepare, CloningInstance, ConvertingInstance, Importing, Completed
27+
}
28+
29+
enum TaskState {
30+
Running, Completed, Failed;
31+
32+
public static TaskState getValue(String state) {
33+
for (TaskState s : TaskState.values()) {
34+
if (s.name().equalsIgnoreCase(state)) {
35+
return s;
36+
}
37+
}
38+
throw new IllegalArgumentException("Invalid task state: " + state);
39+
}
2740
}
2841
}

api/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ ImportVmTask createImportVMTaskRecord(DataCenter zone, Account owner, long userI
3434
void updateImportVMTaskStep(ImportVmTask importVMTaskVO, DataCenter zone, Account owner, Host convertHost,
3535
Host importHost, Long vmId, ImportVmTask.Step step);
3636

37-
boolean removeImportVMTask(long taskId);
37+
void updateImportVMTaskErrorState(ImportVmTask importVMTaskVO, ImportVmTask.TaskState state, String errorMsg);
3838
}

engine/components-api/src/main/java/com/cloud/template/TemplateManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public interface TemplateManager {
5757
+ "will validate if the provided URL is resolvable during the register of templates/ISOs before persisting them in the database.",
5858
true);
5959

60+
ConfigKey<Boolean> TemplateDeleteFromPrimaryStorage = new ConfigKey<Boolean>("Advanced",
61+
Boolean.class,
62+
"template.delete.from.primary.storage", "true",
63+
"Template when deleted will be instantly deleted from the Primary Storage",
64+
true,
65+
ConfigKey.Scope.Global);
66+
6067
static final String VMWARE_TOOLS_ISO = "vmware-tools.iso";
6168
static final String XS_TOOLS_ISO = "xs-tools.iso";
6269

@@ -104,6 +111,8 @@ public interface TemplateManager {
104111
*/
105112
List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool);
106113

114+
void evictTemplateFromStoragePoolsForZones(Long templateId, List<Long> zoneId);
115+
107116
/**
108117
* Deletes a template in the specified storage pool.
109118
*

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4799,6 +4799,18 @@ public NicVO doInTransaction(TransactionStatus status) {
47994799
}
48004800
});
48014801

4802+
if (selectedIp != null && GuestType.Shared.equals(network.getGuestType())) {
4803+
IPAddressVO ipAddressVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), selectedIp);
4804+
if (ipAddressVO != null && IpAddress.State.Free.equals(ipAddressVO.getState())) {
4805+
ipAddressVO.setState(IPAddressVO.State.Allocated);
4806+
ipAddressVO.setAllocatedTime(new Date());
4807+
Account account = _accountDao.findById(vm.getAccountId());
4808+
ipAddressVO.setAllocatedInDomainId(account.getDomainId());
4809+
ipAddressVO.setAllocatedToAccountId(account.getId());
4810+
_ipAddressDao.update(ipAddressVO.getId(), ipAddressVO);
4811+
}
4812+
}
4813+
48024814
final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
48034815
final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
48044816
_networkModel.getNetworkTag(vm.getHypervisorType(), network));
@@ -4810,15 +4822,15 @@ protected String getSelectedIpForNicImport(Network network, DataCenter dataCente
48104822
if (network.getGuestType() == GuestType.L2) {
48114823
return null;
48124824
}
4813-
return dataCenter.getNetworkType() == NetworkType.Basic ?
4814-
getSelectedIpForNicImportOnBasicZone(ipAddresses.getIp4Address(), network, dataCenter):
4825+
return GuestType.Shared.equals(network.getGuestType()) ?
4826+
getSelectedIpForNicImportOnSharedNetwork(ipAddresses.getIp4Address(), network, dataCenter):
48154827
_ipAddrMgr.acquireGuestIpAddress(network, ipAddresses.getIp4Address());
48164828
}
48174829

4818-
protected String getSelectedIpForNicImportOnBasicZone(String requestedIp, Network network, DataCenter dataCenter) {
4830+
protected String getSelectedIpForNicImportOnSharedNetwork(String requestedIp, Network network, DataCenter dataCenter) {
48194831
IPAddressVO ipAddressVO = StringUtils.isBlank(requestedIp) ?
48204832
_ipAddressDao.findBySourceNetworkIdAndDatacenterIdAndState(network.getId(), dataCenter.getId(), IpAddress.State.Free):
4821-
_ipAddressDao.findByIp(requestedIp);
4833+
_ipAddressDao.findByIpAndSourceNetworkId(network.getId(), requestedIp);
48224834
if (ipAddressVO == null || ipAddressVO.getState() != IpAddress.State.Free) {
48234835
String msg = String.format("Cannot find a free IP to assign to VM NIC on network %s", network.getName());
48244836
logger.error(msg);

0 commit comments

Comments
 (0)