mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-2527: enable attach/detach xs tool iso
This commit is contained in:
parent
536feab856
commit
383be568b3
@ -68,7 +68,9 @@ public class TemplateObjectTO implements DataTO {
|
||||
this.accountId = template.getAccountId();
|
||||
this.name = template.getUniqueName();
|
||||
this.format = template.getFormat();
|
||||
this.imageDataStore = template.getDataStore().getTO();
|
||||
if (template.getDataStore() != null) {
|
||||
this.imageDataStore = template.getDataStore().getTO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -175,6 +175,16 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
||||
this.state = TemplateState.Allocated;
|
||||
this.enableSshKey = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public static VMTemplateVO createPreHostIso(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
||||
boolean featured, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId,
|
||||
String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType) {
|
||||
VMTemplateVO template = new VMTemplateVO( id, uniqueName, name, format, isPublic,
|
||||
featured, type, url, created, requiresHvm, bits, accountId,
|
||||
cksum, displayText, enablePassword, guestOSId, bootable, hyperType);
|
||||
template.state = TemplateState.Ready;
|
||||
return template;
|
||||
}
|
||||
|
||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType) {
|
||||
this.id = id;
|
||||
|
||||
@ -266,19 +266,27 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public DataTO getTO() {
|
||||
DataTO to = this.dataStore.getDriver().getTO(this);
|
||||
if (to == null) {
|
||||
to = new TemplateObjectTO(this);
|
||||
}
|
||||
DataTO to = null;
|
||||
if (this.dataStore == null) {
|
||||
to = new TemplateObjectTO(this);
|
||||
} else {
|
||||
to = this.dataStore.getDriver().getTO(this);
|
||||
if (to == null) {
|
||||
to = new TemplateObjectTO(this);
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
DataObjectInStore obj = objectInStoreMgr.findObject(this, this.dataStore);
|
||||
return obj.getInstallPath();
|
||||
}
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
if (this.dataStore == null) {
|
||||
return null;
|
||||
}
|
||||
DataObjectInStore obj = objectInStoreMgr.findObject(this, this.dataStore);
|
||||
return obj.getInstallPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
|
||||
@ -55,11 +55,6 @@
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-secondary-storage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
||||
@ -466,7 +466,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
|
||||
Long id;
|
||||
if (tmplt == null) {
|
||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName,
|
||||
VMTemplateVO template = VMTemplateVO.createPreHostIso(id, isoName, isoName,
|
||||
ImageFormat.ISO, true, true, TemplateType.PERHOST, null,
|
||||
null, true, 64, Account.ACCOUNT_ID_SYSTEM, null,
|
||||
"VMware Tools Installer ISO", false, 1, false,
|
||||
|
||||
@ -543,7 +543,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
Long id;
|
||||
if (tmplt == null) {
|
||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
|
||||
VMTemplateVO template = VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true,
|
||||
TemplateType.PERHOST, null, null, true, 64,
|
||||
Account.ACCOUNT_ID_SYSTEM, null, "xen-pv-drv-iso", false, 1, false, HypervisorType.XenServer);
|
||||
_tmpltDao.persist(template);
|
||||
|
||||
@ -103,12 +103,18 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
DataTO data = disk.getData();
|
||||
DataStoreTO store = data.getDataStore();
|
||||
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
String isoURL = null;
|
||||
if (store == null) {
|
||||
TemplateObjectTO iso = (TemplateObjectTO)disk.getData();
|
||||
isoURL = iso.getName();
|
||||
} else {
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
String isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
|
||||
String vmName = cmd.getVmName();
|
||||
try {
|
||||
@ -237,12 +243,18 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
DataTO data = disk.getData();
|
||||
DataStoreTO store = data.getDataStore();
|
||||
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new DettachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
String isoURL = null;
|
||||
if (store == null) {
|
||||
TemplateObjectTO iso = (TemplateObjectTO)disk.getData();
|
||||
isoURL = iso.getName();
|
||||
} else {
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
String isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
|
||||
try {
|
||||
Connection conn = this.hypervisorResource.getConnection();
|
||||
|
||||
@ -100,11 +100,6 @@
|
||||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
|
||||
@ -69,6 +69,7 @@ import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
|
||||
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
|
||||
import org.apache.cloudstack.api.response.*;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
import org.apache.cloudstack.query.QueryService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -2712,8 +2713,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
}
|
||||
|
||||
if (onlyReady) {
|
||||
sc.addAnd("downloadState", SearchCriteria.Op.EQ, Status.DOWNLOADED);
|
||||
sc.addAnd("destroyed", SearchCriteria.Op.EQ, false);
|
||||
sc.addAnd("state", SearchCriteria.Op.EQ, TemplateState.Ready);
|
||||
}
|
||||
|
||||
if (zoneId != null) {
|
||||
|
||||
@ -28,6 +28,7 @@ import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
@ -239,7 +240,9 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
||||
@Column(name="tag_customer")
|
||||
private String tagCustomer;
|
||||
|
||||
|
||||
@Column(name="state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private TemplateState state;
|
||||
|
||||
public TemplateJoinVO() {
|
||||
}
|
||||
@ -1018,4 +1021,16 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
||||
|
||||
|
||||
|
||||
public TemplateState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setState(TemplateState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1724,6 +1724,7 @@ CREATE VIEW `cloud`.`template_view` AS
|
||||
vm_template.display_text,
|
||||
vm_template.enable_password,
|
||||
vm_template.guest_os_id,
|
||||
vm_template.state,
|
||||
guest_os.uuid guest_os_uuid,
|
||||
guest_os.display_name guest_os_name,
|
||||
vm_template.bootable,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user