Skip to content

Commit 45f6735

Browse files
Renames and adding path
1 parent eab1ca9 commit 45f6735

File tree

11 files changed

+48
-33
lines changed

11 files changed

+48
-33
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ public class ApiConstants {
212212
public static final String EXTENSION = "extension";
213213
public static final String EXTENSIONS = "extensions";
214214
public static final String EXTENSION_ID = "extensionid";
215+
public static final String SCRIPT = "script";
215216
public static final String FENCE = "fence";
216217
public static final String FETCH_LATEST = "fetchlatest";
217218
public static final String FILESYSTEM = "filesystem";

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host', 'last_mgmt_server_id', 'bigin
4040

4141
UPDATE `cloud`.`configuration` SET value = CONCAT(value, ',External') WHERE name = 'hypervisor.list';
4242

43-
CREATE TABLE IF NOT EXISTS `cloud`.`external_orchestrator` (
43+
CREATE TABLE IF NOT EXISTS `cloud`.`extension` (
4444
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
4545
`uuid` varchar(40) NOT NULL UNIQUE,
4646
`name` varchar(255) NOT NULL,
@@ -49,16 +49,16 @@ CREATE TABLE IF NOT EXISTS `cloud`.`external_orchestrator` (
4949
`created` datetime NOT NULL,
5050
`removed` datetime DEFAULT NULL,
5151
PRIMARY KEY (`id`),
52-
CONSTRAINT `fk_external_orchestrator__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`) ON DELETE CASCADE
52+
CONSTRAINT `fk_extension__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`) ON DELETE CASCADE
5353
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5454

55-
CREATE TABLE `cloud`.`external_orchestrator_details` (
55+
CREATE TABLE `cloud`.`extension_details` (
5656
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
57-
`orchestrator_id` bigint unsigned NOT NULL COMMENT 'orchestrator the detail is related to',
57+
`extension_id` bigint unsigned NOT NULL COMMENT 'extension to which the detail is related to',
5858
`name` varchar(255) NOT NULL COMMENT 'name of the detail',
5959
`value` varchar(255) NOT NULL COMMENT 'value of the detail',
6060
`display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user',
6161
PRIMARY KEY (`id`),
62-
CONSTRAINT `fk_orchestrator_details__orchestrator_id` FOREIGN KEY (`orchestrator_id`)
63-
REFERENCES `external_orchestrator` (`id`) ON DELETE CASCADE
62+
CONSTRAINT `fk_extension_details__extension_id` FOREIGN KEY (`extension_id`)
63+
REFERENCES `extension` (`id`) ON DELETE CASCADE
6464
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

plugins/hypervisors/external/src/main/java/com/cloud/agent/manager/ExternalAgentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.cloud.hypervisor.external.provisioner.api.ListExtensionsCmd;
2424
import com.cloud.hypervisor.external.provisioner.api.RegisterExtensionCmd;
2525
import com.cloud.hypervisor.external.provisioner.api.RunCustomActionCmd;
26-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestrator;
26+
import com.cloud.hypervisor.external.provisioner.vo.Extension;
2727
import com.cloud.hypervisor.external.resource.ExternalResourceBase;
2828
import com.cloud.utils.component.Manager;
2929

@@ -43,7 +43,7 @@ public interface ExternalAgentManager extends Manager {
4343

4444
RunCustomActionAnswer runCustomAction(RunCustomActionCmd cmd);
4545

46-
ExternalOrchestrator registerExternalOrchestrator(RegisterExtensionCmd cmd);
46+
Extension registerExternalOrchestrator(RegisterExtensionCmd cmd);
4747

4848
List<ExtensionResponse> listExtensions(ListExtensionsCmd cmd);
4949
}

plugins/hypervisors/external/src/main/java/com/cloud/agent/manager/ExternalAgentManagerImpl.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import com.cloud.hypervisor.external.provisioner.dao.ExternalOrchestratorDetailDao;
4444
import com.cloud.hypervisor.external.provisioner.dao.ExternalOrchestratorDetailVO;
4545
import com.cloud.hypervisor.external.provisioner.simpleprovisioner.SimpleExternalProvisioner;
46-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestrator;
47-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestratorVO;
46+
import com.cloud.hypervisor.external.provisioner.vo.Extension;
47+
import com.cloud.hypervisor.external.provisioner.vo.ExtensionVO;
4848
import com.cloud.hypervisor.external.resource.ExternalResourceBase;
4949
import com.cloud.org.Cluster;
5050
import com.cloud.resource.ResourceService;
@@ -191,12 +191,12 @@ public RunCustomActionAnswer runCustomAction(RunCustomActionCmd cmd) {
191191
}
192192

193193
@Override
194-
public ExternalOrchestrator registerExternalOrchestrator(RegisterExtensionCmd cmd) {
195-
ExternalOrchestratorVO extension = new ExternalOrchestratorVO();
194+
public Extension registerExternalOrchestrator(RegisterExtensionCmd cmd) {
195+
ExtensionVO extension = new ExtensionVO();
196196
extension.setName(cmd.getName());
197197
extension.setType(cmd.getType());
198198
extension.setPodId(cmd.getPodId());
199-
ExternalOrchestratorVO savedExtension = externalOrchestratorDao.persist(extension);
199+
ExtensionVO savedExtension = externalOrchestratorDao.persist(extension);
200200

201201
Map<String, String> externalDetails = cmd.getExternalDetails();
202202
List<ExternalOrchestratorDetailVO> detailsVOList = new ArrayList<>();
@@ -217,13 +217,13 @@ public List<ExtensionResponse> listExtensions(ListExtensionsCmd cmd) {
217217
Long id = cmd.getExtensionId();
218218
String name = cmd.getName();
219219
String keyword = cmd.getKeyword();
220-
final SearchBuilder<ExternalOrchestratorVO> sb = externalOrchestratorDao.createSearchBuilder();
221-
final Filter searchFilter = new Filter(ExternalOrchestratorVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
220+
final SearchBuilder<ExtensionVO> sb = externalOrchestratorDao.createSearchBuilder();
221+
final Filter searchFilter = new Filter(ExtensionVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
222222

223223
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
224224
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
225225
sb.and("keyword", sb.entity().getName(), SearchCriteria.Op.LIKE);
226-
final SearchCriteria<ExternalOrchestratorVO> sc = sb.create();
226+
final SearchCriteria<ExtensionVO> sc = sb.create();
227227

228228
if (id != null) {
229229
sc.setParameters("id", id);
@@ -237,19 +237,21 @@ public List<ExtensionResponse> listExtensions(ListExtensionsCmd cmd) {
237237
sc.setParameters("keyword", "%" + keyword + "%");
238238
}
239239

240-
final Pair<List<ExternalOrchestratorVO>, Integer> result = externalOrchestratorDao.searchAndCount(sc, searchFilter);
240+
final Pair<List<ExtensionVO>, Integer> result = externalOrchestratorDao.searchAndCount(sc, searchFilter);
241241
List<ExtensionResponse> responses = new ArrayList<>();
242-
for (ExternalOrchestratorVO extension : result.first()) {
242+
for (ExtensionVO extension : result.first()) {
243243
Map<String, String> details = externalOrchestratorDetailDao.listDetailsKeyPairs(extension.getId());
244244
ExtensionResponse response = new ExtensionResponse(extension.getName(), extension.getType(), extension.getPodId(), extension.getUuid(), details);
245+
String destinationPath = String.format(SimpleExternalProvisioner.EXTENSION_SCRIPT_PATH, extension.getId());
246+
response.setScriptPath(destinationPath);
245247
response.setObjectName(ApiConstants.EXTENSIONS);
246248
responses.add(response);
247249
}
248250

249251
return responses;
250252
}
251253

252-
private void createRequiredResourcesForExtension(ExternalOrchestratorVO extension, RegisterExtensionCmd registerExtensionCmd) {
254+
private void createRequiredResourcesForExtension(ExtensionVO extension, RegisterExtensionCmd registerExtensionCmd) {
253255
String clusterName = extension.getName() + "-" + extension.getId() + "-cluster";
254256
HostPodVO pod = podDao.findById(extension.getPodId());
255257
AddClusterCmd clusterCmd = new AddClusterCmd(clusterName, pod.getDataCenterId(), pod.getId(), Cluster.ClusterType.CloudManaged.toString(),

plugins/hypervisors/external/src/main/java/com/cloud/hypervisor/external/provisioner/api/ExtensionResponse.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.cloud.hypervisor.external.provisioner.api;
1919

20-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestrator;
20+
import com.cloud.hypervisor.external.provisioner.vo.Extension;
2121
import com.cloud.serializer.Param;
2222
import com.google.gson.annotations.SerializedName;
2323
import org.apache.cloudstack.api.ApiConstants;
@@ -27,7 +27,7 @@
2727
import java.util.Date;
2828
import java.util.Map;
2929

30-
@EntityReference(value = ExternalOrchestrator.class)
30+
@EntityReference(value = Extension.class)
3131
public class ExtensionResponse extends BaseResponse {
3232

3333
@SerializedName(ApiConstants.ID)
@@ -54,6 +54,10 @@ public class ExtensionResponse extends BaseResponse {
5454
@Param(description = "the details of the network")
5555
private Map<String, String> details;
5656

57+
@SerializedName(ApiConstants.SCRIPT)
58+
@Param(description = "the path of the script")
59+
private String script;
60+
5761
@SerializedName(ApiConstants.CREATED)
5862
@Param(description = "Creation timestamp of the extension")
5963
private Date created;
@@ -106,6 +110,14 @@ public void setDetails(Map<String, String> details) {
106110
this.details = details;
107111
}
108112

113+
public String getScriptPath() {
114+
return script;
115+
}
116+
117+
public void setScriptPath(String script) {
118+
this.script = script;
119+
}
120+
109121
public Date getCreated() {
110122
return created;
111123
}

plugins/hypervisors/external/src/main/java/com/cloud/hypervisor/external/provisioner/api/RegisterExtensionCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.cloud.exception.NetworkRuleConflictException;
2424
import com.cloud.exception.ResourceAllocationException;
2525
import com.cloud.exception.ResourceUnavailableException;
26-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestrator;
26+
import com.cloud.hypervisor.external.provisioner.vo.Extension;
2727
import com.cloud.user.Account;
2828
import com.cloud.vm.VmDetailConstants;
2929
import org.apache.cloudstack.api.APICommand;
@@ -103,7 +103,7 @@ public Map getDetails() {
103103

104104
@Override
105105
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
106-
ExternalOrchestrator externalOrchestrator = _externalMgr.registerExternalOrchestrator(this);
106+
Extension externalOrchestrator = _externalMgr.registerExternalOrchestrator(this);
107107
ExtensionResponse response = new ExtensionResponse(name, type, podId, externalOrchestrator.getUuid(), getExternalDetails());
108108
response.setResponseName(getCommandName());
109109
response.setObjectName(ApiConstants.EXTENSION);

plugins/hypervisors/external/src/main/java/com/cloud/hypervisor/external/provisioner/dao/ExternalOrchestratorDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// under the License.
1717
package com.cloud.hypervisor.external.provisioner.dao;
1818

19-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestratorVO;
19+
import com.cloud.hypervisor.external.provisioner.vo.ExtensionVO;
2020
import com.cloud.utils.db.GenericDao;
2121

22-
public interface ExternalOrchestratorDao extends GenericDao<ExternalOrchestratorVO, Long> {
22+
public interface ExternalOrchestratorDao extends GenericDao<ExtensionVO, Long> {
2323
}

plugins/hypervisors/external/src/main/java/com/cloud/hypervisor/external/provisioner/dao/ExternalOrchestratorDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package com.cloud.hypervisor.external.provisioner.dao;
1919

20-
import com.cloud.hypervisor.external.provisioner.vo.ExternalOrchestratorVO;
20+
import com.cloud.hypervisor.external.provisioner.vo.ExtensionVO;
2121
import com.cloud.utils.db.GenericDaoBase;
2222

23-
public class ExternalOrchestratorDaoImpl extends GenericDaoBase<ExternalOrchestratorVO, Long> implements ExternalOrchestratorDao {
23+
public class ExternalOrchestratorDaoImpl extends GenericDaoBase<ExtensionVO, Long> implements ExternalOrchestratorDao {
2424
}

plugins/hypervisors/external/src/main/java/com/cloud/hypervisor/external/provisioner/dao/ExternalOrchestratorDetailVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
import javax.persistence.Table;
2828

2929
@Entity
30-
@Table(name = "external_orchestrator_details")
30+
@Table(name = "extension_details")
3131
public class ExternalOrchestratorDetailVO implements ResourceDetail {
3232
@Id
3333
@GeneratedValue(strategy = GenerationType.IDENTITY)
3434
@Column(name = "id")
3535
private long id;
3636

37-
@Column(name = "orchestrator_id", nullable = false)
37+
@Column(name = "extension_id", nullable = false)
3838
private long resourceId;
3939

4040
@Column(name = "name", nullable = false, length = 255)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
import org.apache.cloudstack.api.Identity;
2121
import org.apache.cloudstack.api.InternalIdentity;
2222

23-
public interface ExternalOrchestrator extends InternalIdentity, Identity {
23+
public interface Extension extends InternalIdentity, Identity {
2424
}

0 commit comments

Comments
 (0)