Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AB560DE5E for ; Sun, 19 May 2013 16:14:56 +0000 (UTC) Received: (qmail 63302 invoked by uid 500); 19 May 2013 16:14:55 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 63185 invoked by uid 500); 19 May 2013 16:14:55 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 62824 invoked by uid 99); 19 May 2013 16:14:55 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 May 2013 16:14:55 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id F1A3E319C56; Sun, 19 May 2013 16:14:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ahuang@apache.org To: commits@cloudstack.apache.org Date: Sun, 19 May 2013 16:14:58 -0000 Message-Id: <1c74299b52654694b535310d2a494dd6@git.apache.org> In-Reply-To: <0ab41a3aab73401d83dd93d18f5314c5@git.apache.org> References: <0ab41a3aab73401d83dd93d18f5314c5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/16] git commit: updated refs/heads/vmsync to f49257c Removed orchestration from relying on cloud-server Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6bf9de59 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6bf9de59 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6bf9de59 Branch: refs/heads/vmsync Commit: 6bf9de596e783552e6ca612bb15c2b37a35093f7 Parents: 813321b Author: Alex Huang Authored: Thu May 16 14:13:54 2013 -0700 Committer: Alex Huang Committed: Thu May 16 14:13:54 2013 -0700 ---------------------------------------------------------------------- .../org/apache/cloudstack/config/ConfigKey.java | 91 +++++ .../cloud/deploy/DeploymentPlanningManager.java | 45 +++ .../org/apache/cloudstack/config/ConfigRepo.java | 26 ++ .../org/apache/cloudstack/config/ConfigValue.java | 72 ++++ .../apache/cloudstack/engine/config/Configs.java | 44 +++ engine/orchestration/pom.xml | 5 - .../engine/vm/VirtualMachineOrchestrator.java | 32 +- engine/schema/pom.xml | 5 + .../com/cloud/vm/VirtualMachineProfileImpl.java | 266 +++++++++++++++ .../apache/cloudstack/vm/jobs/VmWorkJobDao.java | 35 ++ .../cloudstack/vm/jobs/VmWorkJobDaoImpl.java | 118 +++++++ .../org/apache/cloudstack/vm/jobs/VmWorkJobVO.java | 85 +++++ .../storage/test/DirectAgentManagerSimpleImpl.java | 17 +- .../src/com/cloud/configuration/ConfigValue.java | 67 ---- .../cloud/configuration/ConfigurationManager.java | 2 - .../configuration/ConfigurationManagerImpl.java | 7 +- .../cloud/deploy/DeploymentPlanningManager.java | 45 --- .../com/cloud/vm/VirtualMachineManagerImpl.java | 4 +- .../com/cloud/vm/VirtualMachineProfileImpl.java | 266 --------------- server/src/com/cloud/vm/VmWorkJobDao.java | 32 -- server/src/com/cloud/vm/VmWorkJobDaoImpl.java | 116 ------- server/src/com/cloud/vm/VmWorkJobVO.java | 82 ----- .../com/cloud/vm/VmWorkJobWakeupDispatcher.java | 2 + server/test/com/cloud/vm/VmWorkTest.java | 4 +- .../com/cloud/vm/VmWorkTestApiJobDispatcher.java | 1 + .../test/com/cloud/vm/VmWorkTestConfiguration.java | 2 + server/test/com/cloud/vm/dao/VmDaoTest.java | 5 +- .../com/cloud/vm/dao/VmDaoTestConfiguration.java | 5 +- .../cloud/vpc/MockConfigurationManagerImpl.java | 8 - 29 files changed, 825 insertions(+), 664 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/api/src/org/apache/cloudstack/config/ConfigKey.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/config/ConfigKey.java b/api/src/org/apache/cloudstack/config/ConfigKey.java new file mode 100644 index 0000000..2a77a9b --- /dev/null +++ b/api/src/org/apache/cloudstack/config/ConfigKey.java @@ -0,0 +1,91 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.config; + +/** + * ConfigKey supplants the original Config.java. It is just a class + * declaration where others can declare their config variables. + * + * TODO: This class should be moved to a framework project where the gathering + * of these configuration keys should be done by a config server. I + * don't have time yet to do this. Ask me about it if you want to work + * in this area. Right now, we'll just work with the actual names. + */ +public class ConfigKey { + + private final String _category; + + public String category() { + return _category; + } + + public Class component() { + return _componentClass; + } + + public Class type() { + return _type; + } + + public String key() { + return _name; + } + + public String defaultValue() { + return _defaultValue; + } + + public String description() { + return _description; + } + + public String range() { + return _range; + } + + public String scope() { + return _scope; + } + + @Override + public String toString() { + return _name; + } + + private final Class _componentClass; + private final Class _type; + private final String _name; + private final String _defaultValue; + private final String _description; + private final String _range; + private final String _scope; // Parameter can be at different levels (Zone/cluster/pool/account), by default every parameter is at global + + public ConfigKey(Class type, String name, String category, Class componentClass, String defaultValue, String description, String range, String scope) { + _category = category; + _componentClass = componentClass; + _type = type; + _name = name; + _defaultValue = defaultValue; + _description = description; + _range = range; + _scope = scope; + } + + public ConfigKey(Class type, String name, String category, Class componentClass, String defaultValue, String description, String range) { + this(type, name, category, componentClass, defaultValue, description, range, null); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java new file mode 100644 index 0000000..13f1c67 --- /dev/null +++ b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.deploy; + +import com.cloud.deploy.DeploymentPlanner.ExcludeList; +import com.cloud.exception.AffinityConflictException; +import com.cloud.exception.InsufficientServerCapacityException; +import com.cloud.utils.component.Manager; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachineProfile; + +public interface DeploymentPlanningManager extends Manager { + + /** + * Manages vm deployment stages: First Process Affinity/Anti-affinity - Call + * the chain of AffinityGroupProcessor adapters to set deploymentplan scope + * and exclude list Secondly, Call DeploymentPlanner - to use heuristics to + * find the best spot to place the vm/volume. Planner will drill down to the + * write set of clusters to look for placement based on various heuristics. + * Lastly, Call Allocators - Given a cluster, allocators matches the + * requirements to capabilities of the physical resource (host, storage + * pool). + * + * @throws AffinityConflictException + * + * + * + */ + DeployDestination planDeployment(VirtualMachineProfile vmProfile, DeploymentPlan plan, + ExcludeList avoids) throws InsufficientServerCapacityException, AffinityConflictException; +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/components-api/src/org/apache/cloudstack/config/ConfigRepo.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/org/apache/cloudstack/config/ConfigRepo.java b/engine/components-api/src/org/apache/cloudstack/config/ConfigRepo.java new file mode 100644 index 0000000..823d754 --- /dev/null +++ b/engine/components-api/src/org/apache/cloudstack/config/ConfigRepo.java @@ -0,0 +1,26 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.config; + +/** + * ConfigRepo is a repository of configurations. + * + */ +public interface ConfigRepo { + ConfigValue get(ConfigKey key); + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/components-api/src/org/apache/cloudstack/config/ConfigValue.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/org/apache/cloudstack/config/ConfigValue.java b/engine/components-api/src/org/apache/cloudstack/config/ConfigValue.java new file mode 100644 index 0000000..12a3156 --- /dev/null +++ b/engine/components-api/src/org/apache/cloudstack/config/ConfigValue.java @@ -0,0 +1,72 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.config; + +import com.cloud.configuration.ConfigurationVO; +import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.utils.exception.CloudRuntimeException; + +/** + * This is a match set to ConfigKey. + * + * TODO: When we create a framework project for configuration, this should be + * moved there. + */ +public class ConfigValue { + + ConfigKey _config; + ConfigurationDao _dao; + Number _multiplier; + + public ConfigValue(ConfigurationDao dao, ConfigKey config) { + _dao = dao; + _config = config; + _multiplier = 1; + } + + public ConfigKey getConfigKey() { + return _config; + } + + public ConfigValue setMultiplier(Number multiplier) { // Convience method + _multiplier = multiplier; + return this; + } + + @SuppressWarnings("unchecked") + public T value() { + ConfigurationVO vo = _dao.findByName(_config.key()); + String value = vo != null ? vo.getValue() : _config.defaultValue(); + + Class type = _config.type(); + if (type.isAssignableFrom(Boolean.class)) { + return (T)Boolean.valueOf(value); + } else if (type.isAssignableFrom(Integer.class)) { + return (T)new Integer((Integer.parseInt(value) * _multiplier.intValue())); + } else if (type.isAssignableFrom(Long.class)) { + return (T)new Long(Long.parseLong(value) * _multiplier.longValue()); + } else if (type.isAssignableFrom(Short.class)) { + return (T)new Short(Short.parseShort(value)); + } else if (type.isAssignableFrom(String.class)) { + return (T)value; + } else if (type.isAssignableFrom(Float.class)) { + return (T)new Float(Float.parseFloat(value) * _multiplier.floatValue()); + } + + throw new CloudRuntimeException("Unsupported data type for config values: " + type); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/components-api/src/org/apache/cloudstack/engine/config/Configs.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/org/apache/cloudstack/engine/config/Configs.java b/engine/components-api/src/org/apache/cloudstack/engine/config/Configs.java new file mode 100644 index 0000000..aa5ca70 --- /dev/null +++ b/engine/components-api/src/org/apache/cloudstack/engine/config/Configs.java @@ -0,0 +1,44 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.engine.config; + +import org.apache.cloudstack.config.ConfigKey; +import org.apache.cloudstack.engine.service.api.OrchestrationService; + +public interface Configs { + + public static final ConfigKey StartRetry = new ConfigKey( + Integer.class, "start.retry", "Advanced", OrchestrationService.class, "10", "Number of times to retry create and start commands", null); + public static final ConfigKey VmOpWaitInterval = new ConfigKey( + Long.class, "vm.op.wait.interval", "Advanced", OrchestrationService.class, "120", "Time (in seconds) to wait before checking if a previous operation has succeeded", + null); + public static final ConfigKey VmOpLockStateRetry = new ConfigKey( + Integer.class, "vm.op.lock.state.retry", "Advanced", OrchestrationService.class, "5", "Times to retry locking the state of a VM for operations", "-1 means try forever"); + public static final ConfigKey VmOpCleanupInterval = new ConfigKey( + Long.class, "vm.op.cleanup.interval", "Advanced", OrchestrationService.class, "86400", "Interval to run the thread that cleans up the vm operations (in seconds)", + "Seconds"); + public static final ConfigKey VmOpCleanupWait = new ConfigKey( + Long.class, "vm.op.cleanup.wait", "Advanced", OrchestrationService.class, "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"); + public static final ConfigKey VmOpCancelInterval = new ConfigKey( + Integer.class, "vm.op.cancel.interval", "Advanced", OrchestrationService.class, "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"); + + public static final ConfigKey Wait = new ConfigKey( + Integer.class, "wait", "Advanced", OrchestrationService.class, "1800", "Time in seconds to wait for control commands to return", null); + public static final ConfigKey VmDestroyForcestop = new ConfigKey( + Boolean.class, "vm.destroy.forcestop", "Advanced", OrchestrationService.class, "false", "On destroy, force-stop takes this value ", null); + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/orchestration/pom.xml ---------------------------------------------------------------------- diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml index 1ebd0b4..6e02b6d 100755 --- a/engine/orchestration/pom.xml +++ b/engine/orchestration/pom.xml @@ -48,11 +48,6 @@ cloud-utils ${project.version} - - org.apache.cloudstack - cloud-server - ${project.version} - http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/orchestration/src/org/apache/cloudstack/engine/vm/VirtualMachineOrchestrator.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/vm/VirtualMachineOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/vm/VirtualMachineOrchestrator.java index 9cb0cb0..5f1e3d0 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/vm/VirtualMachineOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/vm/VirtualMachineOrchestrator.java @@ -29,11 +29,15 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; +import org.apache.cloudstack.config.ConfigRepo; +import org.apache.cloudstack.config.ConfigValue; import org.apache.cloudstack.engine.cloud.entity.VMEntityVO; import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl; +import org.apache.cloudstack.engine.config.Configs; import org.apache.cloudstack.engine.subsystem.api.storage.StorageOrchestrator; import org.apache.cloudstack.network.NetworkOrchestrator; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -43,9 +47,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.cluster.ManagementServerNode; -import com.cloud.configuration.Config; -import com.cloud.configuration.ConfigValue; -import com.cloud.configuration.ConfigurationManager; import com.cloud.dao.EntityManager; import com.cloud.deploy.DeploymentPlan; import com.cloud.domain.dao.DomainDao; @@ -70,12 +71,10 @@ import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.vm.NicProfile; -import com.cloud.vm.ReservationContextImpl; import com.cloud.vm.UserVmVO; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.VirtualMachineProfileImpl; -import com.cloud.vm.VmWorkJobDao; /** * VirtualMachineOrchestrator orchestrates virtual machine operations. @@ -86,7 +85,7 @@ public class VirtualMachineOrchestrator extends ManagerBase { @Inject EntityManager _entityMgr; @Inject - ConfigurationManager _configMgr; + ConfigRepo _configRepo; @Inject NetworkOrchestrator _networkOrchestrator; @Inject @@ -99,7 +98,7 @@ public class VirtualMachineOrchestrator extends ManagerBase { VirtualMachineManager _itMgr; protected ConfigValue _retry; - protected ConfigValue _cancelWait; + protected ConfigValue _cancelWait; protected ConfigValue _cleanupWait; protected ConfigValue _cleanupInterval; protected ConfigValue _opWaitInterval; @@ -280,16 +279,15 @@ public class VirtualMachineOrchestrator extends ManagerBase { public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - _retry = _configMgr.getConfig(Config.StartRetry, Integer.class); + _retry = _configRepo.get(Configs.StartRetry); - - _cancelWait = _configMgr.getConfig(Config.VmOpCancelInterval, Long.class); - _cleanupWait = _configMgr.getConfig(Config.VmOpCleanupWait, Long.class); - _cleanupInterval = _configMgr.getConfig(Config.VmOpCleanupInterval, Long.class).setMultiplier(1000); - _opWaitInterval = _configMgr.getConfig(Config.VmOpWaitInterval, Long.class).setMultiplier(1000); - _lockStateRetry = _configMgr.getConfig(Config.VmOpLockStateRetry, Integer.class); - _operationTimeout = _configMgr.getConfig(Config.Wait, Integer.class).setMultiplier(2); - _forceStop = _configMgr.getConfig(Config.VmDestroyForcestop, Boolean.class); + _cancelWait = _configRepo.get(Configs.VmOpCancelInterval); + _cleanupWait = _configRepo.get(Configs.VmOpCleanupWait); + _cleanupInterval = _configRepo.get(Configs.VmOpCleanupInterval).setMultiplier(1000); + _opWaitInterval = _configRepo.get(Configs.VmOpWaitInterval).setMultiplier(1000); + _lockStateRetry = _configRepo.get(Configs.VmOpLockStateRetry); + _operationTimeout = _configRepo.get(Configs.Wait).setMultiplier(2); + _forceStop = _configRepo.get(Configs.VmDestroyForcestop); _nodeId = ManagementServerNode.getManagementServerId(); @@ -297,7 +295,7 @@ public class VirtualMachineOrchestrator extends ManagerBase { _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup")); - ReservationContextImpl.setComponents(_userDao, _domainDao, _accountDao); +// ReservationContextImpl.setComponents(_userDao, _domainDao, _accountDao); VirtualMachineProfileImpl.setComponents(_offeringDao, _templateDao, _accountDao); VirtualMachineEntityImpl2.init(_entityMgr, this, _networkOrchestrator, _storageOrchestrator); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/schema/pom.xml ---------------------------------------------------------------------- diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml index 431151a..99b0149 100644 --- a/engine/schema/pom.xml +++ b/engine/schema/pom.xml @@ -33,6 +33,11 @@ cloud-engine-api ${project.version} + + org.apache.cloudstack + cloud-framework-jobs + ${project.version} + install http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/schema/src/com/cloud/vm/VirtualMachineProfileImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/vm/VirtualMachineProfileImpl.java b/engine/schema/src/com/cloud/vm/VirtualMachineProfileImpl.java new file mode 100644 index 0000000..19039f6 --- /dev/null +++ b/engine/schema/src/com/cloud/vm/VirtualMachineProfileImpl.java @@ -0,0 +1,266 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.vm; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.cloud.agent.api.to.VolumeTO; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.offering.ServiceOffering; +import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; +import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.template.VirtualMachineTemplate; +import com.cloud.template.VirtualMachineTemplate.BootloaderType; +import com.cloud.user.Account; +import com.cloud.user.dao.AccountDao; + +/** + * Implementation of VirtualMachineProfile. + * + */ +public class VirtualMachineProfileImpl implements VirtualMachineProfile { + + T _vm; + ServiceOfferingVO _offering; + VMTemplateVO _template; + UserVmDetailVO _userVmDetails; + Map _params; + List _nics = new ArrayList(); + List _disks = new ArrayList(); + StringBuilder _bootArgs = new StringBuilder(); + Account _owner; + BootloaderType _bootloader; + Float cpuOvercommitRatio = 1.0f; + Float memoryOvercommitRatio = 1.0f; + + VirtualMachine.Type _type; + + public VirtualMachineProfileImpl(T vm, VMTemplateVO template, ServiceOfferingVO offering, Account owner, Map params) { + _vm = vm; + _template = template; + _offering = offering; + _params = params; + _owner = owner; + if (_params == null) { + _params = new HashMap(); + } + if (vm != null) + _type = vm.getType(); + } + + public VirtualMachineProfileImpl(T vm) { + this(vm, null, null, null, null); + } + + public VirtualMachineProfileImpl(VirtualMachine.Type type) { + _type = type; + } + + @Override + public String toString() { + return _vm.toString(); + } + + @Override + public T getVirtualMachine() { + return _vm; + } + + @Override + public ServiceOffering getServiceOffering() { + if (_offering == null) { + _offering = s_offeringDao.findByIdIncludingRemoved(_vm.getServiceOfferingId()); + } + return _offering; + } + + @Override + public void setParameter(Param name, Object value) { + _params.put(name, value); + } + + @Override + public void setBootLoaderType(BootloaderType bootLoader) { + this._bootloader = bootLoader; + } + + @Override + public VirtualMachineTemplate getTemplate() { + if (_template == null && _vm != null) { + _template = s_templateDao.findByIdIncludingRemoved(_vm.getTemplateId()); + } + return _template; + } + + @Override + public HypervisorType getHypervisorType() { + return _vm.getHypervisorType(); + } + + @Override + public long getTemplateId() { + return _vm.getTemplateId(); + } + + @Override + public long getServiceOfferingId() { + return _vm.getServiceOfferingId(); + } + + @Override + public long getId() { + return _vm.getId(); + } + + @Override + public String getUuid() { + return _vm.getUuid(); + } + + public void setNics(List nics) { + _nics = nics; + } + + public void setDisks(List disks) { + _disks = disks; + } + + @Override + public List getNics() { + return _nics; + } + + @Override + public List getDisks() { + return _disks; + } + + @Override + public void addNic(int index, NicProfile nic) { + _nics.add(index, nic); + } + + @Override + public void addDisk(int index, VolumeTO disk) { + _disks.add(index, disk); + } + + @Override + public StringBuilder getBootArgsBuilder() { + return _bootArgs; + } + + @Override + public void addBootArgs(String... args) { + for (String arg : args) { + _bootArgs.append(arg).append(" "); + } + } + + @Override + public VirtualMachine.Type getType() { + return _type; + } + + @Override + public Account getOwner() { + if (_owner == null) { + _owner = s_accountDao.findByIdIncludingRemoved(_vm.getAccountId()); + } + return _owner; + } + + @Override + public String getBootArgs() { + return _bootArgs.toString(); + } + + static ServiceOfferingDao s_offeringDao; + static VMTemplateDao s_templateDao; + static AccountDao s_accountDao; + + public static void setComponents(ServiceOfferingDao offeringDao, VMTemplateDao templateDao, AccountDao accountDao) { + s_offeringDao = offeringDao; + s_templateDao = templateDao; + s_accountDao = accountDao; + } + + @Override + public void addNic(NicProfile nic) { + _nics.add(nic); + } + + @Override + public void addDisk(VolumeTO disk) { + _disks.add(disk); + } + + @Override + public Object getParameter(Param name) { + return _params.get(name); + } + + @Override + public String getHostName() { + return _vm.getHostName(); + } + + @Override + public String getInstanceName() { + return _vm.getInstanceName(); + } + + @Override + public BootloaderType getBootLoaderType() { + return this._bootloader; + } + + @Override + public Map getParameters() { + return _params; + } + + public void setServiceOffering(ServiceOfferingVO offering) { + _offering = offering; + } + + public void setcpuOvercommitRatio(Float cpuOvercommitRatio){ + this.cpuOvercommitRatio= cpuOvercommitRatio; + + } + + public void setramOvercommitRatio(Float memoryOvercommitRatio){ + this.memoryOvercommitRatio= memoryOvercommitRatio; + + } + @Override + public Float getCpuOvercommitRatio(){ + return this.cpuOvercommitRatio; + } + + @Override + public Float getMemoryOvercommitRatio(){ + return this.memoryOvercommitRatio; + } + + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDao.java b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDao.java new file mode 100644 index 0000000..735a04a --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDao.java @@ -0,0 +1,35 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.vm.jobs; + +import java.util.Date; +import java.util.List; + +import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step; + +import com.cloud.utils.db.GenericDao; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.Type; + +public interface VmWorkJobDao extends GenericDao { + VmWorkJobVO findPendingWorkJob(VirtualMachine.Type type, long instanceId); + List listPendingWorkJobs(VirtualMachine.Type type, long instanceId); + List listPendingWorkJobs(VirtualMachine.Type type, long instanceId, String jobCmd); + + void updateStep(long workJobId, Step step); + void expungeCompletedWorkJobs(Date cutDate); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDaoImpl.java b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDaoImpl.java new file mode 100644 index 0000000..4ece4e8 --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobDaoImpl.java @@ -0,0 +1,118 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.vm.jobs; + +import java.util.Date; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.apache.cloudstack.framework.jobs.AsyncJobConstants; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step; + +import com.cloud.utils.DateUtil; +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.SearchCriteria.Op; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.Type; + +public class VmWorkJobDaoImpl extends GenericDaoBase implements VmWorkJobDao { + + protected SearchBuilder PendingWorkJobSearch; + protected SearchBuilder PendingWorkJobByCommandSearch; + protected SearchBuilder ExpungeWorkJobSearch; + + public VmWorkJobDaoImpl() { + } + + @PostConstruct + public void init() { + PendingWorkJobSearch = createSearchBuilder(); + PendingWorkJobSearch.and("vmType", PendingWorkJobSearch.entity().getVmType(), Op.EQ); + PendingWorkJobSearch.and("vmInstanceId", PendingWorkJobSearch.entity().getVmInstanceId(), Op.EQ); + PendingWorkJobSearch.and("step", PendingWorkJobSearch.entity().getStep(), Op.NEQ); + PendingWorkJobSearch.done(); + + PendingWorkJobByCommandSearch = createSearchBuilder(); + PendingWorkJobByCommandSearch.and("vmType", PendingWorkJobByCommandSearch.entity().getVmType(), Op.EQ); + PendingWorkJobByCommandSearch.and("vmInstanceId", PendingWorkJobByCommandSearch.entity().getVmInstanceId(), Op.EQ); + PendingWorkJobByCommandSearch.and("step", PendingWorkJobByCommandSearch.entity().getStep(), Op.NEQ); + PendingWorkJobByCommandSearch.and("cmd", PendingWorkJobByCommandSearch.entity().getCmd(), Op.EQ); + PendingWorkJobByCommandSearch.done(); + + ExpungeWorkJobSearch = createSearchBuilder(); + ExpungeWorkJobSearch.and("lastUpdated", ExpungeWorkJobSearch.entity().getLastUpdated(), Op.LT); + ExpungeWorkJobSearch.and("status", ExpungeWorkJobSearch.entity().getStatus(), Op.NEQ); + ExpungeWorkJobSearch.done(); + } + + public VmWorkJobVO findPendingWorkJob(VirtualMachine.Type type, long instanceId) { + + SearchCriteria sc = PendingWorkJobSearch.create(); + sc.setParameters("vmType", type); + sc.setParameters("vmInstanceId", instanceId); + sc.setParameters("step", Step.Done); + + Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); + List result = this.listBy(sc, filter); + if(result != null && result.size() > 0) + return result.get(0); + + return null; + } + + public List listPendingWorkJobs(VirtualMachine.Type type, long instanceId) { + + SearchCriteria sc = PendingWorkJobSearch.create(); + sc.setParameters("vmType", type); + sc.setParameters("vmInstanceId", instanceId); + sc.setParameters("step", Step.Done); + + Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); + return this.listBy(sc, filter); + } + + public List listPendingWorkJobs(VirtualMachine.Type type, long instanceId, String jobCmd) { + + SearchCriteria sc = PendingWorkJobByCommandSearch.create(); + sc.setParameters("vmType", type); + sc.setParameters("vmInstanceId", instanceId); + sc.setParameters("step", Step.Done); + sc.setParameters("cmd", jobCmd); + + Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); + return this.listBy(sc, filter); + } + + public void updateStep(long workJobId, Step step) { + VmWorkJobVO jobVo = findById(workJobId); + jobVo.setStep(step); + jobVo.setLastUpdated(DateUtil.currentGMTTime()); + update(workJobId, jobVo); + } + + public void expungeCompletedWorkJobs(Date cutDate) { + SearchCriteria sc = ExpungeWorkJobSearch.create(); + sc.setParameters("lastUpdated",cutDate); + sc.setParameters("status", AsyncJobConstants.STATUS_IN_PROGRESS); + + expunge(sc); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobVO.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobVO.java b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobVO.java new file mode 100644 index 0000000..bdf8301 --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/vm/jobs/VmWorkJobVO.java @@ -0,0 +1,85 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.vm.jobs; + +import javax.persistence.Column; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +import org.apache.cloudstack.framework.jobs.AsyncJobVO; + +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.Type; + + +@Entity +@Table(name="vm_work_job") +@DiscriminatorValue(value="VmWork") +@PrimaryKeyJoinColumn(name="id") +public class VmWorkJobVO extends AsyncJobVO { + + public enum Step { + Prepare, + Starting, + Started, + Release, + Done, + Migrating, + Reconfiguring + } + + @Column(name="step") + Step step; + + @Column(name="vm_type") + @Enumerated(value=EnumType.STRING) + VirtualMachine.Type vmType; + + @Column(name="vm_instance_id") + long vmInstanceId; + + public VmWorkJobVO() { + } + + public Step getStep() { + return step; + } + + public void setStep(Step step) { + this.step = step; + } + + public VirtualMachine.Type getVmType() { + return vmType; + } + + public void setVmType(VirtualMachine.Type vmType) { + this.vmType = vmType; + } + + public long getVmInstanceId() { + return vmInstanceId; + } + + public void setVmInstanceId(long vmInstanceId) { + this.vmInstanceId = vmInstanceId; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java index 575bc8e..f4a970b 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java @@ -32,11 +32,8 @@ import com.cloud.agent.StartupCommandProcessor; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.SetupCommand; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.manager.AgentAttache; import com.cloud.agent.manager.Commands; import com.cloud.exception.AgentUnavailableException; -import com.cloud.exception.ConnectionException; import com.cloud.exception.OperationTimedoutException; import com.cloud.host.HostEnvironment; import com.cloud.host.HostVO; @@ -49,7 +46,7 @@ import com.cloud.utils.component.ManagerBase; public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentManager { private static final Logger logger = Logger.getLogger(DirectAgentManagerSimpleImpl.class); - private Map hostResourcesMap = new HashMap(); + private final Map hostResourcesMap = new HashMap(); @Inject HostDao hostDao; @Override @@ -193,24 +190,12 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa } @Override - public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException { - // TODO Auto-generated method stub - return null; - } - - @Override public boolean agentStatusTransitTo(HostVO host, Event e, long msId) { // TODO Auto-generated method stub return false; } @Override - public AgentAttache findAttache(long hostId) { - // TODO Auto-generated method stub - return null; - } - - @Override public void disconnectWithoutInvestigation(long hostId, Event event) { // TODO Auto-generated method stub http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/configuration/ConfigValue.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigValue.java b/server/src/com/cloud/configuration/ConfigValue.java deleted file mode 100644 index 967944a..0000000 --- a/server/src/com/cloud/configuration/ConfigValue.java +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.configuration; - -import com.cloud.configuration.dao.ConfigurationDao; -import com.cloud.utils.exception.CloudRuntimeException; - -// This class returns the config value in a class. We can later enhance this -// class to get auto-updated by the database. -public class ConfigValue { - - Config _config; - ConfigurationDao _dao; - Number _multiplier; - - protected ConfigValue(ConfigurationDao dao, Config config) { - _dao = dao; - _config = config; - _multiplier = 1; - } - - public Config getConfig() { - return _config; - } - - public ConfigValue setMultiplier(Number multiplier) { // Convience method - _multiplier = multiplier; - return this; - } - - @SuppressWarnings("unchecked") - public T value() { - ConfigurationVO vo = _dao.findByName(_config.key()); - String value = vo != null ? vo.getValue() : _config.getDefaultValue(); - - Class type = _config.getType(); - if (type.isAssignableFrom(Boolean.class)) { - return (T)Boolean.valueOf(value); - } else if (type.isAssignableFrom(Integer.class)) { - return (T)new Integer((Integer.parseInt(value) * _multiplier.intValue())); - } else if (type.isAssignableFrom(Long.class)) { - return (T)new Long(Long.parseLong(value) * _multiplier.longValue()); - } else if (type.isAssignableFrom(Short.class)) { - return (T)new Short(Short.parseShort(value)); - } else if (type.isAssignableFrom(String.class)) { - return (T)value; - } else if (type.isAssignableFrom(Float.class)) { - return (T)new Float(Float.parseFloat(value) * _multiplier.floatValue()); - } - - throw new CloudRuntimeException("Unsupported data type for config values: " + type); - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/configuration/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index bad67ce..41f62f7 100755 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -242,6 +242,4 @@ public interface ConfigurationManager extends ConfigurationService, Manager { * @return */ String cleanupTags(String tags); - - ConfigValue getConfig(Config config, Class clazz); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 702c38c..0535b1c 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -65,6 +65,9 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd; import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd; import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd; import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd; +import org.apache.cloudstack.config.ConfigKey; +import org.apache.cloudstack.config.ConfigRepo; +import org.apache.cloudstack.config.ConfigValue; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; @@ -187,7 +190,7 @@ import com.cloud.vm.dao.NicDao; import edu.emory.mathcs.backport.java.util.Arrays; @Local(value = { ConfigurationManager.class, ConfigurationService.class }) -public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService { +public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, ConfigRepo { public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class.getName()); @Inject @@ -4485,7 +4488,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } @Override - public ConfigValue getConfig(Config config, Class clazz) { + public ConfigValue get(ConfigKey config) { return new ConfigValue(_configDao, config); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/deploy/DeploymentPlanningManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManager.java b/server/src/com/cloud/deploy/DeploymentPlanningManager.java deleted file mode 100644 index 13f1c67..0000000 --- a/server/src/com/cloud/deploy/DeploymentPlanningManager.java +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.deploy; - -import com.cloud.deploy.DeploymentPlanner.ExcludeList; -import com.cloud.exception.AffinityConflictException; -import com.cloud.exception.InsufficientServerCapacityException; -import com.cloud.utils.component.Manager; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; - -public interface DeploymentPlanningManager extends Manager { - - /** - * Manages vm deployment stages: First Process Affinity/Anti-affinity - Call - * the chain of AffinityGroupProcessor adapters to set deploymentplan scope - * and exclude list Secondly, Call DeploymentPlanner - to use heuristics to - * find the best spot to place the vm/volume. Planner will drill down to the - * write set of clusters to look for placement based on various heuristics. - * Lastly, Call Allocators - Given a cluster, allocators matches the - * requirements to capabilities of the physical resource (host, storage - * pool). - * - * @throws AffinityConflictException - * - * - * - */ - DeployDestination planDeployment(VirtualMachineProfile vmProfile, DeploymentPlan plan, - ExcludeList avoids) throws InsufficientServerCapacityException, AffinityConflictException; -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VirtualMachineManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 28b7d9c..1781017 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -44,6 +44,9 @@ import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.messagebus.TopicConstants; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step; import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager.OnError; @@ -167,7 +170,6 @@ import com.cloud.utils.fsm.StateMachine2; import com.cloud.vm.VirtualMachine.Event; import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachine.State; -import com.cloud.vm.VmWorkJobVO.Step; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.UserVmDetailsDao; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VirtualMachineProfileImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java deleted file mode 100644 index 19039f6..0000000 --- a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java +++ /dev/null @@ -1,266 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.vm; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.cloud.agent.api.to.VolumeTO; -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.offering.ServiceOffering; -import com.cloud.service.ServiceOfferingVO; -import com.cloud.service.dao.ServiceOfferingDao; -import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.dao.VMTemplateDao; -import com.cloud.template.VirtualMachineTemplate; -import com.cloud.template.VirtualMachineTemplate.BootloaderType; -import com.cloud.user.Account; -import com.cloud.user.dao.AccountDao; - -/** - * Implementation of VirtualMachineProfile. - * - */ -public class VirtualMachineProfileImpl implements VirtualMachineProfile { - - T _vm; - ServiceOfferingVO _offering; - VMTemplateVO _template; - UserVmDetailVO _userVmDetails; - Map _params; - List _nics = new ArrayList(); - List _disks = new ArrayList(); - StringBuilder _bootArgs = new StringBuilder(); - Account _owner; - BootloaderType _bootloader; - Float cpuOvercommitRatio = 1.0f; - Float memoryOvercommitRatio = 1.0f; - - VirtualMachine.Type _type; - - public VirtualMachineProfileImpl(T vm, VMTemplateVO template, ServiceOfferingVO offering, Account owner, Map params) { - _vm = vm; - _template = template; - _offering = offering; - _params = params; - _owner = owner; - if (_params == null) { - _params = new HashMap(); - } - if (vm != null) - _type = vm.getType(); - } - - public VirtualMachineProfileImpl(T vm) { - this(vm, null, null, null, null); - } - - public VirtualMachineProfileImpl(VirtualMachine.Type type) { - _type = type; - } - - @Override - public String toString() { - return _vm.toString(); - } - - @Override - public T getVirtualMachine() { - return _vm; - } - - @Override - public ServiceOffering getServiceOffering() { - if (_offering == null) { - _offering = s_offeringDao.findByIdIncludingRemoved(_vm.getServiceOfferingId()); - } - return _offering; - } - - @Override - public void setParameter(Param name, Object value) { - _params.put(name, value); - } - - @Override - public void setBootLoaderType(BootloaderType bootLoader) { - this._bootloader = bootLoader; - } - - @Override - public VirtualMachineTemplate getTemplate() { - if (_template == null && _vm != null) { - _template = s_templateDao.findByIdIncludingRemoved(_vm.getTemplateId()); - } - return _template; - } - - @Override - public HypervisorType getHypervisorType() { - return _vm.getHypervisorType(); - } - - @Override - public long getTemplateId() { - return _vm.getTemplateId(); - } - - @Override - public long getServiceOfferingId() { - return _vm.getServiceOfferingId(); - } - - @Override - public long getId() { - return _vm.getId(); - } - - @Override - public String getUuid() { - return _vm.getUuid(); - } - - public void setNics(List nics) { - _nics = nics; - } - - public void setDisks(List disks) { - _disks = disks; - } - - @Override - public List getNics() { - return _nics; - } - - @Override - public List getDisks() { - return _disks; - } - - @Override - public void addNic(int index, NicProfile nic) { - _nics.add(index, nic); - } - - @Override - public void addDisk(int index, VolumeTO disk) { - _disks.add(index, disk); - } - - @Override - public StringBuilder getBootArgsBuilder() { - return _bootArgs; - } - - @Override - public void addBootArgs(String... args) { - for (String arg : args) { - _bootArgs.append(arg).append(" "); - } - } - - @Override - public VirtualMachine.Type getType() { - return _type; - } - - @Override - public Account getOwner() { - if (_owner == null) { - _owner = s_accountDao.findByIdIncludingRemoved(_vm.getAccountId()); - } - return _owner; - } - - @Override - public String getBootArgs() { - return _bootArgs.toString(); - } - - static ServiceOfferingDao s_offeringDao; - static VMTemplateDao s_templateDao; - static AccountDao s_accountDao; - - public static void setComponents(ServiceOfferingDao offeringDao, VMTemplateDao templateDao, AccountDao accountDao) { - s_offeringDao = offeringDao; - s_templateDao = templateDao; - s_accountDao = accountDao; - } - - @Override - public void addNic(NicProfile nic) { - _nics.add(nic); - } - - @Override - public void addDisk(VolumeTO disk) { - _disks.add(disk); - } - - @Override - public Object getParameter(Param name) { - return _params.get(name); - } - - @Override - public String getHostName() { - return _vm.getHostName(); - } - - @Override - public String getInstanceName() { - return _vm.getInstanceName(); - } - - @Override - public BootloaderType getBootLoaderType() { - return this._bootloader; - } - - @Override - public Map getParameters() { - return _params; - } - - public void setServiceOffering(ServiceOfferingVO offering) { - _offering = offering; - } - - public void setcpuOvercommitRatio(Float cpuOvercommitRatio){ - this.cpuOvercommitRatio= cpuOvercommitRatio; - - } - - public void setramOvercommitRatio(Float memoryOvercommitRatio){ - this.memoryOvercommitRatio= memoryOvercommitRatio; - - } - @Override - public Float getCpuOvercommitRatio(){ - return this.cpuOvercommitRatio; - } - - @Override - public Float getMemoryOvercommitRatio(){ - return this.memoryOvercommitRatio; - } - - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VmWorkJobDao.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VmWorkJobDao.java b/server/src/com/cloud/vm/VmWorkJobDao.java deleted file mode 100644 index 0db811d..0000000 --- a/server/src/com/cloud/vm/VmWorkJobDao.java +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.vm; - -import java.util.Date; -import java.util.List; - -import com.cloud.utils.db.GenericDao; -import com.cloud.vm.VmWorkJobVO.Step; - -public interface VmWorkJobDao extends GenericDao { - VmWorkJobVO findPendingWorkJob(VirtualMachine.Type type, long instanceId); - List listPendingWorkJobs(VirtualMachine.Type type, long instanceId); - List listPendingWorkJobs(VirtualMachine.Type type, long instanceId, String jobCmd); - - void updateStep(long workJobId, Step step); - void expungeCompletedWorkJobs(Date cutDate); -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VmWorkJobDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VmWorkJobDaoImpl.java b/server/src/com/cloud/vm/VmWorkJobDaoImpl.java deleted file mode 100644 index 53c76ed..0000000 --- a/server/src/com/cloud/vm/VmWorkJobDaoImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.vm; - -import java.util.Date; -import java.util.List; - -import javax.annotation.PostConstruct; - -import org.apache.cloudstack.framework.jobs.AsyncJobConstants; - -import com.cloud.utils.DateUtil; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.SearchCriteria.Op; -import com.cloud.vm.VmWorkJobVO.Step; - -public class VmWorkJobDaoImpl extends GenericDaoBase implements VmWorkJobDao { - - protected SearchBuilder PendingWorkJobSearch; - protected SearchBuilder PendingWorkJobByCommandSearch; - protected SearchBuilder ExpungeWorkJobSearch; - - public VmWorkJobDaoImpl() { - } - - @PostConstruct - public void init() { - PendingWorkJobSearch = createSearchBuilder(); - PendingWorkJobSearch.and("vmType", PendingWorkJobSearch.entity().getVmType(), Op.EQ); - PendingWorkJobSearch.and("vmInstanceId", PendingWorkJobSearch.entity().getVmInstanceId(), Op.EQ); - PendingWorkJobSearch.and("step", PendingWorkJobSearch.entity().getStep(), Op.NEQ); - PendingWorkJobSearch.done(); - - PendingWorkJobByCommandSearch = createSearchBuilder(); - PendingWorkJobByCommandSearch.and("vmType", PendingWorkJobByCommandSearch.entity().getVmType(), Op.EQ); - PendingWorkJobByCommandSearch.and("vmInstanceId", PendingWorkJobByCommandSearch.entity().getVmInstanceId(), Op.EQ); - PendingWorkJobByCommandSearch.and("step", PendingWorkJobByCommandSearch.entity().getStep(), Op.NEQ); - PendingWorkJobByCommandSearch.and("cmd", PendingWorkJobByCommandSearch.entity().getCmd(), Op.EQ); - PendingWorkJobByCommandSearch.done(); - - ExpungeWorkJobSearch = createSearchBuilder(); - ExpungeWorkJobSearch.and("lastUpdated", ExpungeWorkJobSearch.entity().getLastUpdated(), Op.LT); - ExpungeWorkJobSearch.and("status", ExpungeWorkJobSearch.entity().getStatus(), Op.NEQ); - ExpungeWorkJobSearch.done(); - } - - public VmWorkJobVO findPendingWorkJob(VirtualMachine.Type type, long instanceId) { - - SearchCriteria sc = PendingWorkJobSearch.create(); - sc.setParameters("vmType", type); - sc.setParameters("vmInstanceId", instanceId); - sc.setParameters("step", Step.Done); - - Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); - List result = this.listBy(sc, filter); - if(result != null && result.size() > 0) - return result.get(0); - - return null; - } - - public List listPendingWorkJobs(VirtualMachine.Type type, long instanceId) { - - SearchCriteria sc = PendingWorkJobSearch.create(); - sc.setParameters("vmType", type); - sc.setParameters("vmInstanceId", instanceId); - sc.setParameters("step", Step.Done); - - Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); - return this.listBy(sc, filter); - } - - public List listPendingWorkJobs(VirtualMachine.Type type, long instanceId, String jobCmd) { - - SearchCriteria sc = PendingWorkJobByCommandSearch.create(); - sc.setParameters("vmType", type); - sc.setParameters("vmInstanceId", instanceId); - sc.setParameters("step", Step.Done); - sc.setParameters("cmd", jobCmd); - - Filter filter = new Filter(VmWorkJobVO.class, "created", true, null, null); - return this.listBy(sc, filter); - } - - public void updateStep(long workJobId, Step step) { - VmWorkJobVO jobVo = findById(workJobId); - jobVo.setStep(step); - jobVo.setLastUpdated(DateUtil.currentGMTTime()); - update(workJobId, jobVo); - } - - public void expungeCompletedWorkJobs(Date cutDate) { - SearchCriteria sc = ExpungeWorkJobSearch.create(); - sc.setParameters("lastUpdated",cutDate); - sc.setParameters("status", AsyncJobConstants.STATUS_IN_PROGRESS); - - expunge(sc); - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VmWorkJobVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VmWorkJobVO.java b/server/src/com/cloud/vm/VmWorkJobVO.java deleted file mode 100644 index 8cea54f..0000000 --- a/server/src/com/cloud/vm/VmWorkJobVO.java +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.vm; - -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.PrimaryKeyJoinColumn; -import javax.persistence.Table; - -import org.apache.cloudstack.framework.jobs.AsyncJobVO; - - -@Entity -@Table(name="vm_work_job") -@DiscriminatorValue(value="VmWork") -@PrimaryKeyJoinColumn(name="id") -public class VmWorkJobVO extends AsyncJobVO { - - public enum Step { - Prepare, - Starting, - Started, - Release, - Done, - Migrating, - Reconfiguring - } - - @Column(name="step") - Step step; - - @Column(name="vm_type") - @Enumerated(value=EnumType.STRING) - VirtualMachine.Type vmType; - - @Column(name="vm_instance_id") - long vmInstanceId; - - public VmWorkJobVO() { - } - - public Step getStep() { - return step; - } - - public void setStep(Step step) { - this.step = step; - } - - public VirtualMachine.Type getVmType() { - return vmType; - } - - public void setVmType(VirtualMachine.Type vmType) { - this.vmType = vmType; - } - - public long getVmInstanceId() { - return vmInstanceId; - } - - public void setVmInstanceId(long vmInstanceId) { - this.vmInstanceId = vmInstanceId; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/src/com/cloud/vm/VmWorkJobWakeupDispatcher.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VmWorkJobWakeupDispatcher.java b/server/src/com/cloud/vm/VmWorkJobWakeupDispatcher.java index 08584ed..17963f7 100644 --- a/server/src/com/cloud/vm/VmWorkJobWakeupDispatcher.java +++ b/server/src/com/cloud/vm/VmWorkJobWakeupDispatcher.java @@ -30,6 +30,8 @@ import org.apache.cloudstack.framework.jobs.AsyncJob; import org.apache.cloudstack.framework.jobs.AsyncJobDispatcher; import org.apache.cloudstack.framework.jobs.AsyncJobJoinMapVO; import org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO; import com.cloud.api.ApiSerializerHelper; import com.cloud.user.AccountVO; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vm/VmWorkTest.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/VmWorkTest.java b/server/test/com/cloud/vm/VmWorkTest.java index 4f91aba..3cb78da 100644 --- a/server/test/com/cloud/vm/VmWorkTest.java +++ b/server/test/com/cloud/vm/VmWorkTest.java @@ -46,11 +46,13 @@ import com.cloud.utils.LogUtils; import com.cloud.utils.Predicate; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.db.Transaction; -import com.cloud.vm.VmWorkJobVO.Step; import com.google.gson.Gson; import org.apache.cloudstack.framework.jobs.AsyncJobManager; import org.apache.cloudstack.framework.jobs.AsyncJobVO; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations="classpath:/VmWorkTestContext.xml") http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vm/VmWorkTestApiJobDispatcher.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/VmWorkTestApiJobDispatcher.java b/server/test/com/cloud/vm/VmWorkTestApiJobDispatcher.java index 5166372..258f88d 100644 --- a/server/test/com/cloud/vm/VmWorkTestApiJobDispatcher.java +++ b/server/test/com/cloud/vm/VmWorkTestApiJobDispatcher.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import org.apache.cloudstack.framework.jobs.AsyncJob; import org.apache.cloudstack.framework.jobs.AsyncJobDispatcher; import org.apache.cloudstack.framework.jobs.AsyncJobManager; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO; import com.cloud.api.ApiSerializerHelper; import com.cloud.async.AsyncJobExecutionContext; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vm/VmWorkTestConfiguration.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/VmWorkTestConfiguration.java b/server/test/com/cloud/vm/VmWorkTestConfiguration.java index 9db06f8..b436b16 100644 --- a/server/test/com/cloud/vm/VmWorkTestConfiguration.java +++ b/server/test/com/cloud/vm/VmWorkTestConfiguration.java @@ -33,6 +33,8 @@ import org.apache.cloudstack.framework.jobs.dao.SyncQueueDao; import org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl; import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDao; import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobDaoImpl; import com.cloud.api.ApiDispatcher; import com.cloud.cluster.ClusterManager; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vm/dao/VmDaoTest.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/dao/VmDaoTest.java b/server/test/com/cloud/vm/dao/VmDaoTest.java index b22c203..d981916 100644 --- a/server/test/com/cloud/vm/dao/VmDaoTest.java +++ b/server/test/com/cloud/vm/dao/VmDaoTest.java @@ -29,13 +29,14 @@ import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobVO; + import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.db.Transaction; import com.cloud.vm.UserVmVO; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VmWorkJobDao; -import com.cloud.vm.VmWorkJobVO; import junit.framework.Assert; import junit.framework.TestCase; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vm/dao/VmDaoTestConfiguration.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/dao/VmDaoTestConfiguration.java b/server/test/com/cloud/vm/dao/VmDaoTestConfiguration.java index 6b0a15a..46d9501 100644 --- a/server/test/com/cloud/vm/dao/VmDaoTestConfiguration.java +++ b/server/test/com/cloud/vm/dao/VmDaoTestConfiguration.java @@ -20,6 +20,9 @@ import org.mockito.Mockito; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.apache.cloudstack.vm.jobs.VmWorkJobDao; +import org.apache.cloudstack.vm.jobs.VmWorkJobDaoImpl; + import com.cloud.cluster.agentlb.dao.HostTransferMapDao; import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl; import com.cloud.dc.dao.ClusterDao; @@ -30,8 +33,6 @@ import com.cloud.host.dao.HostDaoImpl; import com.cloud.host.dao.HostDetailsDao; import com.cloud.host.dao.HostTagsDao; import com.cloud.tags.dao.ResourceTagDao; -import com.cloud.vm.VmWorkJobDao; -import com.cloud.vm.VmWorkJobDaoImpl; @Configuration public class VmDaoTestConfiguration { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bf9de59/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index d221f3c..bd6893b 100755 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -48,8 +48,6 @@ import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd; import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd; import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd; -import com.cloud.configuration.Config; -import com.cloud.configuration.ConfigValue; import com.cloud.configuration.Configuration; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationService; @@ -633,10 +631,4 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu return false; } - @Override - public ConfigValue getConfig(Config config, Class clazz) { - // TODO Auto-generated method stub - return null; - } - }