diff --git a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index f131714ecaf0..396e71c5a02d 100644 --- a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -32,6 +32,8 @@ import org.apache.cloudstack.agent.lb.IndirectAgentLB; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.security.keys.KeysManager; import org.apache.cloudstack.framework.security.keystore.KeystoreDao; @@ -153,7 +155,7 @@ // Starting, HA, Migrating, Running state are all counted as "Open" for available capacity calculation // because sooner or later, it will be driven into Running state // -public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxyManager, VirtualMachineGuru, SystemVmLoadScanHandler, ResourceStateAdapter { +public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxyManager, VirtualMachineGuru, SystemVmLoadScanHandler, ResourceStateAdapter, Configurable { private static final Logger s_logger = Logger.getLogger(ConsoleProxyManagerImpl.class); private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 seconds @@ -250,6 +252,19 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy @Inject private KeystoreManager _ksMgr; + private static final ConfigKey ConsoleProxyTemplateXenServer = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.xenserver", + "SystemVM Template (XenServer)", "Name of the console proxy template on Xenserver.", true); + private static final ConfigKey ConsoleProxyTemplateKVM = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.kvm", "SystemVM Template (KVM)", + "Name of the console proxy template on KVM.", true); + private static final ConfigKey ConsoleProxyTemplateVMware = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.vmware", + "SystemVM Template (vSphere)", "Name of the console proxy template on VMware.", true); + private static final ConfigKey ConsoleProxyTemplateHyperV = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.hyperv", + "SystemVM Template (HyperV)", "Name of the console proxy template on Hyperv.", true); + private static final ConfigKey ConsoleProxyTemplateLxc = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.lxc", "SystemVM Template (LXC)", + "Name of the console proxy template on LXC.", true); + private static final ConfigKey ConsoleProxyTemplateOvm3 = new ConfigKey("Console Proxy", String.class, "consoleproxy.template.ovm3", "SystemVM Template (Ovm3)", + "Name of the console proxy template on Ovm3.", true); + public class VmBasedAgentHook extends AgentHookBase { public VmBasedAgentHook(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao, KeystoreManager ksMgr, AgentManager agentMgr, KeysManager keysMgr) { @@ -642,9 +657,34 @@ public ConsoleProxyVO startNew(long dataCenterId) throws ConcurrentOperationExce VMTemplateVO template = null; HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId); - template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor); + + String templateName = null; + switch (availableHypervisor) { + case XenServer: + templateName = ConsoleProxyTemplateXenServer.value(); + break; + case KVM: + templateName = ConsoleProxyTemplateKVM.value(); + break; + case VMware: + templateName = ConsoleProxyTemplateVMware.value(); + break; + case Hyperv: + templateName = ConsoleProxyTemplateHyperV.value(); + break; + case LXC: + templateName = ConsoleProxyTemplateLxc.value(); + break; + case Ovm3: + templateName = ConsoleProxyTemplateOvm3.value(); + break; + default: + break; + } + template = _templateDao.findRoutingTemplate(availableHypervisor, templateName); + if (template == null) { - throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); + throw new CloudRuntimeException("Not able to find the Console Proxy System template or not downloaded in zone " + dataCenterId); } Map context = createProxyInstance(dataCenterId, template); @@ -1735,4 +1775,15 @@ public void setConsoleProxyAllocators(List consoleProxyAl _consoleProxyAllocators = consoleProxyAllocators; } + @Override + public String getConfigComponentName() { + return ConsoleProxyManagerImpl.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {ConsoleProxyTemplateXenServer, ConsoleProxyTemplateKVM, ConsoleProxyTemplateVMware, ConsoleProxyTemplateHyperV, ConsoleProxyTemplateLxc, + ConsoleProxyTemplateOvm3}; + } + } diff --git a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 66c436b15c33..2c13e4d5dc0c 100644 --- a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -263,6 +263,18 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar private final GlobalLock _allocLock = GlobalLock.getInternLock(getAllocLockName()); + private static final ConfigKey SsvmTemplateXenServer = new ConfigKey("Storage", String.class, "ssvm.template.xenserver", "SystemVM Template (XenServer)", + "Name of the SSVM template on Xenserver.", true); + private static final ConfigKey SsvmTemplateKVM = new ConfigKey("Storage", String.class, "ssvm.template.kvm", "SystemVM Template (KVM)", + "Name of the SSVM template on KVM.", true); + private static final ConfigKey SsvmTemplateVMware = new ConfigKey("Storage", String.class, "ssvm.template.vmware", "SystemVM Template (vSphere)", + "Name of the SSVM template on VMware.", true); + private static final ConfigKey SsvmTemplateHyperV = new ConfigKey("Storage", String.class, "ssvm.template.hyperv", "SystemVM Template (HyperV)", + "Name of the SSVM template on Hyperv.", true); + private static final ConfigKey SsvmTemplateLxc = new ConfigKey("Storage", String.class, "ssvm.template.lxc", "SystemVM Template (LXC)", + "Name of the SSVM template on LXC.", true); + private static final ConfigKey SsvmTemplateOvm3 = new ConfigKey("Storage", String.class, "ssvm.template.ovm3", "SystemVM Template (Ovm3)", + "Name of the SSVM template on Ovm3.", true); static final ConfigKey NTPServerConfig = new ConfigKey(String.class, "ntp.server.list", "Advanced", null, "Comma separated list of NTP servers to configure in Secondary storage VM", false, ConfigKey.Scope.Global, null); @@ -642,9 +654,33 @@ protected Map createSecStorageVmInstance(long dataCenterId, Seco VMTemplateVO template = null; HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId); - template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor); + + String templateName = null; + switch (availableHypervisor) { + case XenServer: + templateName = SsvmTemplateXenServer.value(); + break; + case KVM: + templateName = SsvmTemplateKVM.value(); + break; + case VMware: + templateName = SsvmTemplateVMware.value(); + break; + case Hyperv: + templateName = SsvmTemplateHyperV.value(); + break; + case LXC: + templateName = SsvmTemplateLxc.value(); + case Ovm3: + templateName = SsvmTemplateOvm3.value(); + break; + default: + break; + } + template = _templateDao.findRoutingTemplate(availableHypervisor, templateName); + if (template == null) { - throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); + throw new CloudRuntimeException("Not able to find the Secondary Storage System template or not downloaded in zone " + dataCenterId); } ServiceOfferingVO serviceOffering = _serviceOffering; @@ -1510,7 +1546,7 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {NTPServerConfig}; + return new ConfigKey[] {NTPServerConfig, SsvmTemplateXenServer, SsvmTemplateKVM, SsvmTemplateVMware, SsvmTemplateHyperV, SsvmTemplateLxc, SsvmTemplateOvm3}; } }