Skip to content

Commit ed2bf1a

Browse files
Few code improvements
1 parent 3e86874 commit ed2bf1a

File tree

10 files changed

+20
-13
lines changed

10 files changed

+20
-13
lines changed

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public interface VmDetailConstants {
121121

122122
// External orchestrator related
123123
String MAC_ADDRESS = "mac_address";
124-
String EXPUNGE_EXTERNAL_SERVER = "expunge.external.server";
124+
String EXPUNGE_EXTERNAL_VM = "expunge.external.vm";
125125
String EXTERNAL_DETAIL_PREFIX = "External:";
126126
String CLOUDSTACK_VM_DETAILS = "cloudstack.vm.details";
127127
String CLOUDSTACK_VLAN = "cloudstack.vlan";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ public class ApiConstants {
674674
public static final String NETWORK_DEVICE_PARAMETER_LIST = "networkdeviceparameterlist";
675675
public static final String ZONE_TOKEN = "zonetoken";
676676
public static final String DHCP_PROVIDER = "dhcpprovider";
677-
public static final String RESULT = "success";
678-
public static final String RESULT1 = "result";
677+
public static final String RESULT = "result";
679678
public static final String RESUME = "resume";
680679
public static final String LUN_ID = "lunId";
681680
public static final String IQN = "iqn";

api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
186186
since = "4.20")
187187
private String arch;
188188

189-
@Parameter(name = ApiConstants.EXTENSION_ID, type = CommandType.UUID, entityType = ExtensionResponse.class, description = "UUID of the extension")
189+
@Parameter(name = ApiConstants.EXTENSION_ID, type = CommandType.UUID, entityType = ExtensionResponse.class, description = "UUID of the extension", since = "4.21.0")
190190
private Long extensionId;
191191

192192
@Parameter(name = ApiConstants.EXTERNAL_DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format externaldetails[i].keyname=keyvalue. Example: externaldetails[0].endpoint.url=urlvalue", since = "4.21.0")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CreateConsoleEndpointResponse extends BaseResponse {
2626
public CreateConsoleEndpointResponse() {
2727
}
2828

29-
@SerializedName(ApiConstants.RESULT)
29+
@SerializedName(ApiConstants.SUCCESS)
3030
@Param(description = "true if the console endpoint is generated properly")
3131
private Boolean result;
3232

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class RouterHealthCheckResultResponse extends BaseResponse {
3434
@Param(description = "the type of the health check - basic or advanced")
3535
private String checkType;
3636

37-
@SerializedName(ApiConstants.RESULT)
37+
@SerializedName(ApiConstants.SUCCESS)
3838
@Param(description = "result of the health check")
3939
private boolean result;
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public class UnmanageVMInstanceResponse extends BaseResponse {
2626

27-
@SerializedName(ApiConstants.RESULT)
27+
@SerializedName(ApiConstants.SUCCESS)
2828
@Param(description = "result of the unmanage VM operation")
2929
private boolean success;
3030

api/src/main/java/org/apache/cloudstack/extension/CustomActionResultResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CustomActionResultResponse extends BaseResponse {
3939
@Param(description = "Whether custom action succeed or not")
4040
private Boolean success;
4141

42-
@SerializedName(ApiConstants.RESULT1)
42+
@SerializedName(ApiConstants.RESULT)
4343
@Param(description = "Result of the action execution")
4444
private Map<String, String> result;
4545

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableExcepti
671671
if (HypervisorType.External.equals(vm.getHypervisorType())) {
672672
UserVmVO userVM = _userVmDao.findById(vm.getId());
673673
_userVmDao.loadDetails(userVM);
674-
userVM.setDetail(VmDetailConstants.EXPUNGE_EXTERNAL_SERVER, Boolean.TRUE.toString());
674+
userVM.setDetail(VmDetailConstants.EXPUNGE_EXTERNAL_VM, Boolean.TRUE.toString());
675675
_userVmDao.saveDetails(userVM);
676676
}
677677

framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,11 @@ public ExtensionResourceMap registerExtensionWithCluster(Cluster cluster, Extens
812812
ExtensionResourceMapVO existing =
813813
extensionResourceMapDao.findByResourceIdAndType(cluster.getId(), resourceType);
814814
if (existing != null) {
815-
throw new CloudRuntimeException("Extension already registered with this resource");
815+
if (existing.getExtensionId() == extension.getId()) {
816+
throw new CloudRuntimeException("Extension is already registered with this resource");
817+
} else {
818+
throw new CloudRuntimeException("Another extension is already registered with this resource");
819+
}
816820
}
817821
ExtensionResourceMap result = Transaction.execute((TransactionCallbackWithException<ExtensionResourceMap, CloudRuntimeException>) status -> {
818822
ExtensionResourceMapVO extensionMap = new ExtensionResourceMapVO(extension.getId(), cluster.getId(), resourceType);

plugins/hypervisors/external/src/main/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisioner.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ private String getServerProperty(String name) {
228228
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
229229
super.configure(name, params);
230230

231+
initializeExtensionDirectories();
232+
checkExtensionsDirectory();
233+
createOrCheckExtensionsDataDirectory();
234+
return true;
235+
}
236+
237+
private void initializeExtensionDirectories() {
231238
String deploymentMode = getServerProperty(EXTENSIONS_DEPLOYMENT_MODE_NAME);
232239
if ("developer".equals(deploymentMode)) {
233240
extensionsDirectory = EXTENSIONS_DIRECTORY_DEV;
@@ -236,9 +243,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
236243
extensionsDirectory = EXTENSIONS_DIRECTORY_PROD;
237244
extensionsDataDirectory = EXTENSIONS_DATA_DIRECTORY_PROD;
238245
}
239-
checkExtensionsDirectory();
240-
createOrCheckExtensionsDataDirectory();
241-
return true;
242246
}
243247

244248
@Override

0 commit comments

Comments
 (0)