Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
  • Loading branch information
shwstppr committed Nov 19, 2025
commit bc2280425c68273b142e78c4d06f1916f4b12ff5
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand All @@ -41,6 +38,7 @@
import org.apache.commons.lang3.StringUtils;

import com.cloud.hypervisor.ExternalProvisioner;
import com.cloud.utils.FileUtil;
import com.cloud.utils.HttpUtils;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.Transaction;
Expand Down Expand Up @@ -92,14 +90,12 @@ protected Extension importExtensionInternal(String manifestUrl, Path tempDir) {
false, Collections.emptyMap());

for (ExtensionConfig.CustomAction action : extensionConfig.spec.customActions) {
List<Map<String, String>> parameters = action.getParametersMapList();
Map<Integer, Collection<Map<String, String>>> parametersMap = new HashMap<>();
parametersMap.put(1, parameters);
Map<Integer, Map<String, String>> parameters = action.getParametersAsMap();
extensionsManager.addCustomAction(action.name, action.description, extension.getId(),
action.resourcetype, action.allowedroletypes, action.timeout, true, parametersMap,
action.resourcetype, action.allowedroletypes, action.timeout, true, parameters,
null, null, Collections.emptyMap());
}
return null;
return extension;
});
}

Expand All @@ -123,8 +119,8 @@ public Extension importExtension(ImportExtensionCmd cmd) {
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
}/* finally {
} finally {
FileUtil.deletePath(tempDir.toString());
}*/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.apache.cloudstack.framework.extensions.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.cloudstack.api.ApiConstants;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

Expand Down Expand Up @@ -99,15 +101,18 @@ public static class CustomAction {
public List<String> allowedroletypes;
public List<Parameter> parameters;

public List<Map<String, String>> getParametersMapList() {
return parameters.stream().map(param -> {
Map<String, String> paramMap = new java.util.HashMap<>();
paramMap.put("name", param.name);
paramMap.put("type", param.type);
paramMap.put("validationformat", param.validationformat);
paramMap.put("required", Boolean.toString(param.required));
return paramMap;
}).collect(Collectors.toList());
public Map<Integer, Map<String, String>> getParametersAsMap() {
Map<Integer, Map<String, String>> paramMap = new HashMap<>();
int index = 0;
for (Parameter param : parameters) {
Map<String, String> singleParamMap = new HashMap<>();
singleParamMap.put(ApiConstants.NAME, param.name);
singleParamMap.put(ApiConstants.TYPE, param.type);
singleParamMap.put(ApiConstants.VALIDATION_FORMAT, param.validationformat);
singleParamMap.put(ApiConstants.REQUIRED, Boolean.toString(param.required));
paramMap.put(index++, singleParamMap);
}
return paramMap;
}
}

Expand All @@ -119,7 +124,13 @@ public static class Parameter {
}

public String getArchiveUrl() {
return source.url + "archive/refs/heads/" + source.refs + ".zip";
String type = source != null ? source.type : null;
if ("git".equalsIgnoreCase(type) && source.url != null && source.url.contains("github.com")) {
// ToDo: improve
String ref = source.refs != null ? source.refs : "main";
return source.url.replace("github.com", "codeload.github.com") + "/zip/refs/heads/" + ref;
}
return source == null ? null : source.url;
}

public Spec getSpec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class YamlParserTest extends TestCase {

@Test
public void testParseYaml() {
String yamlFilePath = getClass().getResource("manifest.yaml").getFile();
YamlParser.parseYamlFile(yamlFilePath);
String yamlFilePath = getClass().getResource("testmanifest.yaml").getFile();
ExtensionConfig config = YamlParser.parseYamlFile(yamlFilePath);
assertNotNull(config);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ apiVersion: cloudstack.apache.org/v1
kind: OrchestratorExtension

metadata:
name: firecracker
displayName: Firecracker Extension
name: test
displayName: Test Extension
description: >
External orchestrator extension that integrates Firecracker microVMs
with Apache CloudStack via the Orchestrator Extension Framework.
Test extension via the Orchestrator Extension Framework.
version: 0.1.0
maintainer: "Marco Sinhoreli <msinhore@gmail.com>"
homepage: "https://github.com/msinhore/cloudstack-firecracker-extension"
maintainer: "Test Maintainer <maintainer@test.com>"
homepage: "https://github.com/maintainer/test"

source:
type: git
url: "https://github.com/msinhore/cloudstack-firecracker-extension"
url: "https://github.com/maintainer/test"
refs: "branchName"

spec:
Expand All @@ -25,8 +24,8 @@ spec:

entrypoint:
language: python
Comment thread
shwstppr marked this conversation as resolved.
Outdated
path: firecracker.py
targetDir: /usr/share/cloudstack-management/extensions/firecracker
path: test.py
targetDir: /usr/share/cloudstack-management/extensions/test

orchestrator:
requiresPrepareVm: false
Expand Down
Loading