Need to set all the system vms as read state

This commit is contained in:
edison 2010-09-30 20:37:44 -07:00
parent 6b31058d4f
commit b441deec94
6 changed files with 54 additions and 16 deletions

View File

@ -1635,6 +1635,23 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
if (secondaryPool == null) { if (secondaryPool == null) {
return new Answer(cmd, false, " Failed to create storage pool"); 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); tmplVol = getVolume(secondaryPool, getPathOfStoragePool(secondaryPool) + tmpltname);
if (tmplVol == null) { if (tmplVol == null) {
return new Answer(cmd, false, " Can't find volume"); return new Answer(cmd, false, " Can't find volume");

View File

@ -18,7 +18,9 @@
package com.cloud.storage.resource; package com.cloud.storage.resource;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.naming.ConfigurationException; 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.DownloadAnswer;
import com.cloud.agent.api.storage.DownloadCommand; import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.agent.api.storage.DownloadProgressCommand; import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.host.Host; import com.cloud.host.Host;
import com.cloud.host.Host.Type; import com.cloud.host.Host.Type;
import com.cloud.resource.ServerResource; import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase; import com.cloud.resource.ServerResourceBase;
import com.cloud.server.ManagementServer;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Storage.StoragePoolType; 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.storage.template.TemplateInfo;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
public class DummySecondaryStorageResource extends ServerResourceBase implements ServerResource { public class DummySecondaryStorageResource extends ServerResourceBase implements ServerResource {
private static final Logger s_logger = Logger.getLogger(DummySecondaryStorageResource.class); private static final Logger s_logger = Logger.getLogger(DummySecondaryStorageResource.class);
@ -53,9 +62,10 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
String _pod; String _pod;
String _guid; String _guid;
String _dummyPath; String _dummyPath;
VMTemplateDao _tmpltDao;
private boolean _useServiceVm; private boolean _useServiceVm;
public DummySecondaryStorageResource(boolean useServiceVM) { public DummySecondaryStorageResource(boolean useServiceVM) {
setUseServiceVm(useServiceVM); setUseServiceVm(useServiceVM);
} }
@ -114,9 +124,7 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
cmd.setName(_guid); cmd.setName(_guid);
cmd.setVersion(DummySecondaryStorageResource.class.getPackage().getImplementationVersion()); cmd.setVersion(DummySecondaryStorageResource.class.getPackage().getImplementationVersion());
/* gather TemplateInfo in second storage */ /* gather TemplateInfo in second storage */
final Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>(); cmd.setTemplateInfo(getDefaultSystemVmTemplateInfo());
tInfo.put("routing", TemplateInfo.getDefaultSystemVmTemplateInfo());
cmd.setTemplateInfo(tInfo);
cmd.getHostDetails().put("mount.parent", "dummy"); cmd.getHostDetails().put("mount.parent", "dummy");
cmd.getHostDetails().put("mount.path", "dummy"); cmd.getHostDetails().put("mount.path", "dummy");
cmd.getHostDetails().put("orig.url", _guid); cmd.getHostDetails().put("orig.url", _guid);
@ -150,6 +158,12 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
if (_dummyPath == null) { if (_dummyPath == null) {
throw new ConfigurationException("Unable to find mount.path"); 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; return true;
} }
@ -160,4 +174,16 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
public boolean useServiceVm() { public boolean useServiceVm() {
return _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;
}
} }

View File

@ -25,7 +25,7 @@ public final class TemplateConstants {
public static final String DEFAULT_TMPLT_ROOT_DIR = "template/"; public static final String DEFAULT_TMPLT_ROOT_DIR = "template/";
public static final String DEFAULT_TMPLT_FIRST_LEVEL_DIR = "tmpl/"; 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_SYSTEM_VM_DB_ID = 1L;
public static final long DEFAULT_BUILTIN_VM_DB_ID = 2L; public static final long DEFAULT_BUILTIN_VM_DB_ID = 2L;

View File

@ -22,14 +22,8 @@ public class TemplateInfo {
String installPath; String installPath;
long size; long size;
long id; long id;
boolean isPublic; 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() { protected TemplateInfo() {
} }

View File

@ -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), 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"), 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), 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"), 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), 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), 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),

View File

@ -196,6 +196,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov
Map<ServerResource, Map<String, String>> srs = new HashMap<ServerResource, Map<String, String>>(); Map<ServerResource, Map<String, String>> srs = new HashMap<ServerResource, Map<String, String>>();
DummySecondaryStorageResource storage = new DummySecondaryStorageResource(_useServiceVM); DummySecondaryStorageResource storage = new DummySecondaryStorageResource(_useServiceVM);
Map<String, String> details = new HashMap<String, String>(); Map<String, String> details = new HashMap<String, String>();
details.put("mount.path", uri.toString()); details.put("mount.path", uri.toString());