mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Need to set all the system vms as read state
This commit is contained in:
parent
6b31058d4f
commit
b441deec94
@ -1635,6 +1635,23 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
if (secondaryPool == null) {
|
||||
return new Answer(cmd, false, " Failed to create storage pool");
|
||||
}
|
||||
if (tmpltname == null) {
|
||||
/*Hack: server just pass the directory of system vm template, need to scan the folder */
|
||||
secondaryPool.refresh(0);
|
||||
String[] volumes = secondaryPool.listVolumes();
|
||||
if (volumes == null) {
|
||||
return new Answer(cmd, false, "Failed to get volumes from pool: " + secondaryPool.getName());
|
||||
}
|
||||
for (String volumeName : volumes) {
|
||||
if (volumeName.endsWith("qcow2")) {
|
||||
tmpltname = volumeName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmpltname == null) {
|
||||
return new Answer(cmd, false, "Failed to get template from pool: " + secondaryPool.getName());
|
||||
}
|
||||
}
|
||||
tmplVol = getVolume(secondaryPool, getPathOfStoragePool(secondaryPool) + tmpltname);
|
||||
if (tmplVol == null) {
|
||||
return new Answer(cmd, false, " Can't find volume");
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
|
||||
package com.cloud.storage.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -38,13 +40,20 @@ import com.cloud.agent.api.StartupStorageCommand;
|
||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
import com.cloud.agent.api.storage.DownloadCommand;
|
||||
import com.cloud.agent.api.storage.DownloadProgressCommand;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.ServerResourceBase;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.template.TemplateConstants;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
public class DummySecondaryStorageResource extends ServerResourceBase implements ServerResource {
|
||||
private static final Logger s_logger = Logger.getLogger(DummySecondaryStorageResource.class);
|
||||
@ -53,8 +62,9 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
|
||||
String _pod;
|
||||
String _guid;
|
||||
String _dummyPath;
|
||||
|
||||
private boolean _useServiceVm;
|
||||
VMTemplateDao _tmpltDao;
|
||||
private boolean _useServiceVm;
|
||||
|
||||
|
||||
public DummySecondaryStorageResource(boolean useServiceVM) {
|
||||
setUseServiceVm(useServiceVM);
|
||||
@ -114,9 +124,7 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
|
||||
cmd.setName(_guid);
|
||||
cmd.setVersion(DummySecondaryStorageResource.class.getPackage().getImplementationVersion());
|
||||
/* gather TemplateInfo in second storage */
|
||||
final Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
|
||||
tInfo.put("routing", TemplateInfo.getDefaultSystemVmTemplateInfo());
|
||||
cmd.setTemplateInfo(tInfo);
|
||||
cmd.setTemplateInfo(getDefaultSystemVmTemplateInfo());
|
||||
cmd.getHostDetails().put("mount.parent", "dummy");
|
||||
cmd.getHostDetails().put("mount.path", "dummy");
|
||||
cmd.getHostDetails().put("orig.url", _guid);
|
||||
@ -149,7 +157,13 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
|
||||
_dummyPath = (String)params.get("mount.path");
|
||||
if (_dummyPath == null) {
|
||||
throw new ConfigurationException("Unable to find mount.path");
|
||||
}
|
||||
}
|
||||
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
_tmpltDao = locator.getDao(VMTemplateDao.class);
|
||||
if (_tmpltDao == null) {
|
||||
throw new ConfigurationException("Unable to find VMTemplate dao");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -159,5 +173,17 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
|
||||
|
||||
public boolean useServiceVm() {
|
||||
return _useServiceVm;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, TemplateInfo> getDefaultSystemVmTemplateInfo() {
|
||||
List<VMTemplateVO> tmplts = _tmpltDao.listAllRoutingTemplates();
|
||||
Map<String, TemplateInfo> tmpltInfo = new HashMap<String, TemplateInfo>();
|
||||
if (tmplts != null) {
|
||||
for (VMTemplateVO tmplt : tmplts) {
|
||||
TemplateInfo routingInfo = new TemplateInfo(tmplt.getUniqueName(), TemplateConstants.DEFAULT_SYSTEM_VM_TEMPLATE_PATH + tmplt.getId() + File.separator, false);
|
||||
tmpltInfo.put(tmplt.getUniqueName(), routingInfo);
|
||||
}
|
||||
}
|
||||
return tmpltInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public final class TemplateConstants {
|
||||
public static final String DEFAULT_TMPLT_ROOT_DIR = "template/";
|
||||
public static final String DEFAULT_TMPLT_FIRST_LEVEL_DIR = "tmpl/";
|
||||
|
||||
public static final String DEFAULT_SYSTEM_VM_TEMPLATE_PATH = "template/tmpl/1/1/";
|
||||
public static final String DEFAULT_SYSTEM_VM_TEMPLATE_PATH = "template/tmpl/1/";
|
||||
public static final long DEFAULT_SYSTEM_VM_DB_ID = 1L;
|
||||
public static final long DEFAULT_BUILTIN_VM_DB_ID = 2L;
|
||||
|
||||
|
||||
@ -22,14 +22,8 @@ public class TemplateInfo {
|
||||
String installPath;
|
||||
long size;
|
||||
long id;
|
||||
|
||||
boolean isPublic;
|
||||
|
||||
public static TemplateInfo getDefaultSystemVmTemplateInfo() {
|
||||
TemplateInfo routingInfo = new TemplateInfo(TemplateConstants.DEFAULT_SYSTEM_VM_TMPLT_NAME, TemplateConstants.DEFAULT_SYSTEM_VM_TEMPLATE_PATH, false);
|
||||
return routingInfo;
|
||||
}
|
||||
|
||||
|
||||
protected TemplateInfo() {
|
||||
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public enum Config {
|
||||
CPUOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "cpu.overprovisioning.factor", "1", "Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", null),
|
||||
NetworkType("Advanced", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"),
|
||||
LinkLocalIpNums("Advanced", ManagementServer.class, Integer.class, "linkLocalIp.nums", "10", "The number of link local ip that needed by domR(in power of 2)", null),
|
||||
HypervisorDefaultType("Advanced", ManagementServer.class, String.class, "hypervisor.type", HypervisorType.KVM.toString(), "The type of hypervisor that this deployment will use.", "kvm|xenserver"),
|
||||
HypervisorDefaultType("Advanced", ManagementServer.class, String.class, "hypervisor.type", HypervisorType.KVM.toString(), "The type of hypervisor that this deployment will use.", "kvm,xenserver"),
|
||||
HypervisorList("Advanced", ManagementServer.class, String.class, "hypervisor.list", HypervisorType.KVM + "," + HypervisorType.XenServer + "," + HypervisorType.VmWare, "The list of hypervisors that this deployment will use.", "kvm,xenserver,vmware"),
|
||||
ManagementHostIPAdr("Advanced", ManagementServer.class, String.class, "host", "localhost", "The ip address of management server", null),
|
||||
UseSecondaryStorageVm("Advanced", ManagementServer.class, Boolean.class, "secondary.storage.vm", "false", "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server", null),
|
||||
|
||||
@ -196,6 +196,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov
|
||||
Map<ServerResource, Map<String, String>> srs = new HashMap<ServerResource, Map<String, String>>();
|
||||
|
||||
DummySecondaryStorageResource storage = new DummySecondaryStorageResource(_useServiceVM);
|
||||
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
|
||||
details.put("mount.path", uri.toString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user