mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Moved NetworkManagerImpl to NetworkOrchestrator
This commit is contained in:
parent
8e5249df62
commit
2e5bb63f77
@ -29,7 +29,6 @@ import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
@ -196,10 +195,9 @@ public interface NetworkGuru extends Adapter {
|
||||
*
|
||||
* @param network guest network being destroyed.
|
||||
* @param offering network offering the guest network was created with.
|
||||
* @param owner owner of the network.
|
||||
* @return true if trash was successful; false if not.
|
||||
*/
|
||||
boolean trash(Network network, NetworkOffering offering, Account owner);
|
||||
boolean trash(Network network, NetworkOffering offering);
|
||||
|
||||
void updateNetworkProfile(NetworkProfile networkProfile);
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.Type;
|
||||
@ -61,6 +62,8 @@ public interface VolumeOrchestrationService {
|
||||
|
||||
String getVmNameOnVolume(Volume volume);
|
||||
|
||||
VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot) throws StorageUnavailableException;
|
||||
|
||||
Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException;
|
||||
|
||||
void destroyVolume(Volume volume);
|
||||
|
||||
@ -33,11 +33,21 @@
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-schema</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-jobs</artifactId>
|
||||
|
||||
@ -17,28 +17,28 @@
|
||||
|
||||
package com.cloud.event;
|
||||
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import org.apache.cloudstack.framework.events.Event;
|
||||
import org.apache.cloudstack.framework.events.EventBus;
|
||||
import org.apache.cloudstack.framework.events.EventBusException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
||||
import org.apache.cloudstack.framework.events.Event;
|
||||
import org.apache.cloudstack.framework.events.EventBus;
|
||||
import org.apache.cloudstack.framework.events.EventBusException;
|
||||
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
public class UsageEventUtils {
|
||||
|
||||
private static UsageEventDao _usageEventDao;
|
||||
@ -141,7 +141,7 @@ public class UsageEventUtils {
|
||||
if (account == null)
|
||||
return;
|
||||
|
||||
Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
|
||||
Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
|
||||
resourceType, resourceUUID);
|
||||
|
||||
Map<String, String> eventDescription = new HashMap<String, String>();
|
||||
@ -162,4 +162,7 @@ public class UsageEventUtils {
|
||||
s_logger.warn("Failed to publish usage event on the the event bus.");
|
||||
}
|
||||
}
|
||||
|
||||
static final String Name = "management-server";
|
||||
|
||||
}
|
||||
@ -30,9 +30,9 @@ import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface LoadBalancingRulesManager extends LoadBalancingRulesService {
|
||||
public interface LoadBalancingRulesManager {
|
||||
|
||||
LoadBalancer createPublicLoadBalancer(String xId, String name, String description,
|
||||
LoadBalancer createPublicLoadBalancer(String xId, String name, String description,
|
||||
int srcPort, int destPort, long sourceIpId, String protocol, String algorithm, boolean openFirewall, CallContext caller)
|
||||
throws NetworkRuleConflictException;
|
||||
|
||||
@ -21,13 +21,11 @@ import java.util.List;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
@ -37,7 +35,7 @@ import com.cloud.utils.Pair;
|
||||
/**
|
||||
* TemplateManager manages the templates stored on secondary storage. It is responsible for creating private/public templates.
|
||||
*/
|
||||
public interface TemplateManager extends TemplateApiService{
|
||||
public interface TemplateManager {
|
||||
|
||||
/**
|
||||
* Prepares a template for vm creation for a certain storage pool.
|
||||
@ -43,6 +43,11 @@
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
@ -57,10 +62,9 @@
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
package org.apache.cloudstack.engine.orchestration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
@ -37,28 +37,17 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.lf5.viewer.configure.ConfigurationManager;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.context.ServerContexts;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.region.PortableIpDao;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckNetworkAnswer;
|
||||
import com.cloud.agent.api.CheckNetworkCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
@ -67,7 +56,6 @@ import com.cloud.dc.DataCenterVnetVO;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterVnetDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
@ -76,7 +64,6 @@ import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
@ -91,14 +78,23 @@ import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.IpAddress.State;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Event;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkMigrationResponder;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.AccountGuestVlanMapDao;
|
||||
import com.cloud.network.dao.AccountGuestVlanMapVO;
|
||||
@ -128,18 +124,13 @@ import com.cloud.network.element.StaticNatServiceProvider;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.rules.FirewallManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.StaticNatRuleImpl;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
@ -149,13 +140,10 @@ import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDetailsDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
@ -196,11 +184,11 @@ import com.cloud.vm.dao.VMInstanceDao;
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
@Local(value = { NetworkOrchestrationService.class})
|
||||
public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrationService, Listener {
|
||||
static final Logger s_logger = Logger.getLogger(NetworkManagerImpl.class);
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestrationService, Listener {
|
||||
static final Logger s_logger = Logger.getLogger(NetworkOrchestrator.class);
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr = null;
|
||||
@Inject
|
||||
DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
@ -210,10 +198,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
@Inject
|
||||
AccountDao _accountDao = null;
|
||||
@Inject
|
||||
DomainDao _domainDao = null;
|
||||
@Inject
|
||||
UserDao _userDao = null;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
UserVmDao _userVmDao = null;
|
||||
@ -224,8 +208,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
AccountVlanMapDao _accountVlanMapDao;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao = null;
|
||||
@Inject
|
||||
NetworkDao _networksDao = null;
|
||||
@ -318,8 +300,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
StorageNetworkManager _stnwMgr;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
PrivateIpDao _privateIpDao;
|
||||
@ -612,7 +592,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
return true;
|
||||
}
|
||||
|
||||
protected NetworkManagerImpl() {
|
||||
protected NetworkOrchestrator() {
|
||||
setStateMachine();
|
||||
}
|
||||
|
||||
@ -2103,7 +2083,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
@Override
|
||||
@DB
|
||||
public boolean destroyNetwork(long networkId, ReservationContext context) {
|
||||
Account callerAccount = _accountMgr.getAccount(context.getCaller().getAccountId());
|
||||
Account callerAccount = context.getAccount();
|
||||
|
||||
NetworkVO network = _networksDao.findById(networkId);
|
||||
if (network == null) {
|
||||
@ -2194,11 +2174,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
s_logger.debug("Network id=" + networkId + " is destroyed successfully, cleaning up corresponding resources now.");
|
||||
}
|
||||
NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName());
|
||||
Account owner = _accountMgr.getAccount(network.getAccountId());
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
guru.trash(network, _networkOfferingDao.findById(network.getNetworkOfferingId()), owner);
|
||||
guru.trash(network, _networkOfferingDao.findById(network.getNetworkOfferingId()));
|
||||
|
||||
if (!deleteVlansInNetwork(network.getId(), context.getCaller().getId(), callerAccount)) {
|
||||
success = false;
|
||||
@ -2223,7 +2202,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
|
||||
if (updateResourceCount) {
|
||||
_resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
|
||||
_resourceLimitMgr.decrementResourceCount(network.getAccountId(), ResourceType.network);
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
@ -2266,6 +2245,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
public class NetworkGarbageCollector implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ServerContexts.registerSystemContext();
|
||||
GlobalLock gcLock = GlobalLock.getInternLock("Network.GC.Lock");
|
||||
try {
|
||||
if(gcLock.lock(3)) {
|
||||
@ -2277,6 +2257,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
}
|
||||
} finally {
|
||||
gcLock.releaseRef();
|
||||
ServerContexts.unregisterSystemContext();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2311,6 +2292,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
|
||||
_lastNetworkIdsToFree = stillFree;
|
||||
|
||||
CallContext cctx = CallContext.current();
|
||||
|
||||
for (Long networkId : shutdownList) {
|
||||
|
||||
// If network is removed, unset gc flag for it
|
||||
@ -2320,8 +2303,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkOrchestrat
|
||||
} else {
|
||||
try {
|
||||
|
||||
User caller = _accountMgr.getSystemUser();
|
||||
Account owner = _accountMgr.getAccount(_networksDao.findById(networkId).getAccountId());
|
||||
User caller = cctx.getCallingUser();
|
||||
Account owner = cctx.getCallingAccount();
|
||||
|
||||
ReservationContext context = new ReservationContextImpl(null, null, caller, owner);
|
||||
|
||||
@ -45,7 +45,10 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.ConfigValue;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
@ -55,7 +58,7 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.agent.manager.allocator.PodAllocator;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
@ -73,7 +76,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Snapshot;
|
||||
@ -91,7 +93,6 @@ import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -106,7 +107,7 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
|
||||
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService {
|
||||
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
|
||||
private static final Logger s_logger = Logger.getLogger(VolumeOrchestrator.class);
|
||||
|
||||
@Inject
|
||||
@ -124,10 +125,6 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
@Inject
|
||||
protected ResourceLimitService _resourceLimitMgr;
|
||||
@Inject
|
||||
protected ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
VolumeDetailsDao _volDetailDao;
|
||||
@Inject
|
||||
DataStoreManager dataStoreMgr;
|
||||
@ -139,9 +136,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
TemplateDataFactory tmplFactory;
|
||||
@Inject
|
||||
SnapshotDataFactory snapshotFactory;
|
||||
@Inject
|
||||
ConfigDepot _configDepot;
|
||||
|
||||
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
|
||||
private long _maxVolumeSizeInGb;
|
||||
private boolean _recreateSystemVmEnabled;
|
||||
private ConfigValue<Long> _maxVolumeSizeInGb;
|
||||
private ConfigValue<Boolean> _recreateSystemVmEnabled;
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||
@ -152,6 +152,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
this._storagePoolAllocators = _storagePoolAllocators;
|
||||
}
|
||||
|
||||
protected List<PodAllocator> _podAllocators;
|
||||
|
||||
public List<PodAllocator> getPodAllocators() {
|
||||
return _podAllocators;
|
||||
}
|
||||
|
||||
public void setPodAllocators(List<PodAllocator> _podAllocators) {
|
||||
this._podAllocators = _podAllocators;
|
||||
}
|
||||
|
||||
protected VolumeOrchestrator() {
|
||||
_volStateMachine = Volume.State.getStateMachine();
|
||||
}
|
||||
@ -243,8 +253,19 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
return null;
|
||||
}
|
||||
|
||||
public Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc, long accountId, Set<Long> avoids) {
|
||||
for (PodAllocator allocator : _podAllocators) {
|
||||
final Pair<Pod, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
|
||||
if (pod != null) {
|
||||
return pod;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected VolumeInfo createVolumeFromSnapshot(VolumeVO volume, Snapshot snapshot) throws StorageUnavailableException {
|
||||
@Override
|
||||
public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot) throws StorageUnavailableException {
|
||||
Account account = _entityMgr.findById(Account.class, volume.getAccountId());
|
||||
|
||||
final HashSet<StoragePool> poolsToAvoid = new HashSet<StoragePool>();
|
||||
@ -258,7 +279,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
DiskProfile dskCh = new DiskProfile(volume, diskOffering, snapshot.getHypervisorType());
|
||||
|
||||
// Determine what pod to store the volume in
|
||||
while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(), podsToAvoid)) != null) {
|
||||
while ((pod = findPod(null, null, dc, account.getId(), podsToAvoid)) != null) {
|
||||
podsToAvoid.add(pod.first().getId());
|
||||
// Determine what storage pool to store the volume in
|
||||
while ((pool = findStoragePool(dskCh, dc, pod.first(), null, null, null, poolsToAvoid)) != null) {
|
||||
@ -322,25 +343,6 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
}
|
||||
}
|
||||
|
||||
protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId) throws StorageUnavailableException {
|
||||
VolumeInfo createdVolume = null;
|
||||
Snapshot snapshot = _entityMgr.findById(Snapshot.class, snapshotId);
|
||||
createdVolume = createVolumeFromSnapshot(volume, snapshot);
|
||||
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE,
|
||||
createdVolume.getAccountId(),
|
||||
createdVolume.getDataCenterId(),
|
||||
createdVolume.getId(),
|
||||
createdVolume.getName(),
|
||||
createdVolume.getDiskOfferingId(),
|
||||
null,
|
||||
createdVolume.getSize(),
|
||||
Volume.class.getName(),
|
||||
createdVolume.getUuid());
|
||||
|
||||
return _volsDao.findById(createdVolume.getId());
|
||||
}
|
||||
|
||||
@DB
|
||||
public VolumeInfo copyVolumeFromSecToPrimary(VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId,
|
||||
ServiceOffering offering, DiskOffering diskOffering, List<StoragePool> avoids, long size, HypervisorType hyperType) throws NoTransitionException {
|
||||
@ -487,7 +489,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
public boolean validateVolumeSizeRange(long size) {
|
||||
if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
|
||||
throw new InvalidParameterValueException("Please specify a size of at least 1 Gb.");
|
||||
} else if (size > (_maxVolumeSizeInGb * 1024 * 1024 * 1024)) {
|
||||
} else if (size > (_maxVolumeSizeInGb.value() * 1024 * 1024 * 1024)) {
|
||||
throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + _maxVolumeSizeInGb + " Gb.");
|
||||
}
|
||||
|
||||
@ -907,7 +909,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
}
|
||||
|
||||
private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool> destVols) throws StorageUnavailableException {
|
||||
boolean recreate = _recreateSystemVmEnabled;
|
||||
boolean recreate = _recreateSystemVmEnabled.value();
|
||||
List<VolumeTask> tasks = new ArrayList<VolumeTask>();
|
||||
for (VolumeVO vol : vols) {
|
||||
StoragePoolVO assignedPool = null;
|
||||
@ -979,7 +981,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
|
||||
private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException {
|
||||
VolumeVO newVol;
|
||||
boolean recreate = _recreateSystemVmEnabled;
|
||||
boolean recreate = _recreateSystemVmEnabled.value();
|
||||
DataStore destPool = null;
|
||||
if (recreate && (dest.getStorageForDisks() == null || dest.getStorageForDisks().get(vol) == null)) {
|
||||
destPool = dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
|
||||
@ -1091,14 +1093,36 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final ConfigKey<Long> MaxVolumeSize = new ConfigKey<Long>(Long.class,
|
||||
"storage.max.volume.size",
|
||||
"Storage",
|
||||
"2000",
|
||||
"The maximum size for a volume (in GB).",
|
||||
true);
|
||||
|
||||
public static final ConfigKey<Boolean> RecreatableSystemVmEnabled = new ConfigKey<Boolean>(Boolean.class,
|
||||
"recreate.systemvm.enabled",
|
||||
"Advanced",
|
||||
"false",
|
||||
"If true, will recreate system vm root disk whenever starting system vm",
|
||||
true);
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return VolumeOrchestrationService.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
String maxVolumeSizeInGbString = _configDao.getValue("storage.max.volume.size");
|
||||
_maxVolumeSizeInGb = NumbersUtil.parseLong(maxVolumeSizeInGbString, 2000);
|
||||
_maxVolumeSizeInGb = _configDepot.get(MaxVolumeSize);
|
||||
|
||||
String value = _configDao.getValue(Config.RecreateSystemVmEnabled.key());
|
||||
_recreateSystemVmEnabled = Boolean.parseBoolean(value);
|
||||
_recreateSystemVmEnabled = _configDepot.get(RecreatableSystemVmEnabled);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -38,20 +38,10 @@
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -23,21 +23,17 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.host.Host;
|
||||
@ -48,6 +44,7 @@ import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
@ -73,8 +70,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
@Inject
|
||||
VMTemplateDetailsDao _templateDetailsDao;
|
||||
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
|
||||
@ -254,8 +254,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering,
|
||||
Account owner) {
|
||||
return super.trash(network, offering, owner);
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,10 +170,9 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering,
|
||||
Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
s_logger.debug("trash called with network: " + network.toString());
|
||||
|
||||
return super.trash(network, offering, owner);
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ public class MidoNetPublicNetworkGuru extends PublicNetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
s_logger.debug("trash called with network: " + network.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -256,9 +256,8 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering,
|
||||
Account owner) {
|
||||
return super.trash(network, offering, owner);
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,6 +50,13 @@
|
||||
<artifactId>cloud-framework-jobs</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-orchestration</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
@ -111,6 +118,11 @@
|
||||
<artifactId>cloud-framework-config</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-components-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
@ -232,7 +232,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network config, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network config, NetworkOffering offering) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +303,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
//Have to remove all placeholder nics
|
||||
List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkId(network.getId());
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
@ -424,7 +424,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network config, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network config, NetworkOffering offering) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ public class StorageNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -162,7 +161,6 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { LoadBalancingRulesManager.class, LoadBalancingRulesService.class })
|
||||
public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements LoadBalancingRulesManager,
|
||||
LoadBalancingRulesService {
|
||||
|
||||
@ -18,14 +18,11 @@ package com.cloud.resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodCluster;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
@ -34,10 +31,7 @@ import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.resource.ResourceState.Event;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
||||
/**
|
||||
@ -117,16 +111,6 @@ public interface ResourceManager extends ResourceService {
|
||||
|
||||
public List<HostVO> listHostsByNameLike(String name);
|
||||
|
||||
/**
|
||||
* Find a pod based on the user id, template, and data center.
|
||||
*
|
||||
* @param template
|
||||
* @param dc
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc, long accountId, Set<Long> avoids);
|
||||
|
||||
HostStats getHostStatistics(long hostId);
|
||||
|
||||
Long getGuestOSCategoryId(long hostId);
|
||||
|
||||
@ -25,7 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
@ -67,7 +66,6 @@ import com.cloud.agent.api.UnsupportedAnswer;
|
||||
import com.cloud.agent.api.UpdateHostPasswordCommand;
|
||||
import com.cloud.agent.manager.AgentAttache;
|
||||
import com.cloud.agent.manager.ClusteredAgentManagerImpl;
|
||||
import com.cloud.agent.manager.allocator.PodAllocator;
|
||||
import com.cloud.agent.transport.Request;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.capacity.Capacity;
|
||||
@ -79,13 +77,11 @@ import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
import com.cloud.dc.ClusterDetailsVO;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterIpAddressVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DedicatedResourceVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodCluster;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.ClusterVSMMapDao;
|
||||
@ -119,7 +115,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
@ -136,11 +131,9 @@ import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.UriUtils;
|
||||
import com.cloud.utils.component.Manager;
|
||||
@ -237,15 +230,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
@Inject
|
||||
protected StoragePoolHostDao _storagePoolHostDao;
|
||||
|
||||
protected List<PodAllocator> _podAllocators;
|
||||
|
||||
public List<PodAllocator> getPodAllocators() {
|
||||
return _podAllocators;
|
||||
}
|
||||
|
||||
public void setPodAllocators(List<PodAllocator> _podAllocators) {
|
||||
this._podAllocators = _podAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
protected VMTemplateDao _templateDao;
|
||||
@ -2472,17 +2456,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc, long accountId,
|
||||
Set<Long> avoids) {
|
||||
for (PodAllocator allocator : _podAllocators) {
|
||||
final Pair<Pod, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
|
||||
if (pod != null) {
|
||||
return pod;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostStats getHostStatistics(long hostId) {
|
||||
|
||||
@ -18,10 +18,8 @@ package com.cloud.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -48,7 +46,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
@ -86,7 +83,6 @@ import com.cloud.consoleproxy.ConsoleProxyManager;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
@ -140,7 +136,6 @@ import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.user.dao.VmDiskStatisticsDao;
|
||||
import com.cloud.utils.EnumUtils;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.UriUtils;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -149,7 +144,6 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
@ -692,7 +686,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId) throws StorageUnavailableException {
|
||||
VolumeInfo createdVolume = null;
|
||||
SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
|
||||
createdVolume = createVolumeFromSnapshot(volume, snapshot);
|
||||
createdVolume = _volumeMgr.createVolumeFromSnapshot(volume, snapshot);
|
||||
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(), createdVolume.getDataCenterId(), createdVolume.getId(),
|
||||
createdVolume.getName(), createdVolume.getDiskOfferingId(), null, createdVolume.getSize(), Volume.class.getName(), createdVolume.getUuid());
|
||||
@ -700,56 +694,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
return _volsDao.findById(createdVolume.getId());
|
||||
}
|
||||
|
||||
@DB
|
||||
protected VolumeInfo createVolumeFromSnapshot(VolumeVO volume, SnapshotVO snapshot) throws StorageUnavailableException {
|
||||
Account account = _accountDao.findById(volume.getAccountId());
|
||||
|
||||
final HashSet<StoragePool> poolsToAvoid = new HashSet<StoragePool>();
|
||||
StoragePool pool = null;
|
||||
|
||||
Set<Long> podsToAvoid = new HashSet<Long>();
|
||||
Pair<Pod, Long> pod = null;
|
||||
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findByIdIncludingRemoved(volume.getDiskOfferingId());
|
||||
DataCenterVO dc = _dcDao.findById(volume.getDataCenterId());
|
||||
DiskProfile dskCh = new DiskProfile(volume, diskOffering, snapshot.getHypervisorType());
|
||||
|
||||
// Determine what pod to store the volume in
|
||||
while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(), podsToAvoid)) != null) {
|
||||
podsToAvoid.add(pod.first().getId());
|
||||
// Determine what storage pool to store the volume in
|
||||
while ((pool = _volumeMgr.findStoragePool(dskCh, dc, pod.first(), null, null, null, poolsToAvoid)) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pool == null) {
|
||||
String msg = "There are no available storage pools to store the volume in";
|
||||
s_logger.info(msg);
|
||||
throw new StorageUnavailableException(msg, -1);
|
||||
}
|
||||
|
||||
VolumeInfo vol = volFactory.getVolume(volume.getId());
|
||||
DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
|
||||
SnapshotInfo snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), DataStoreRole.Image);
|
||||
AsyncCallFuture<VolumeApiResult> future = volService.createVolumeFromSnapshot(vol, store, snapInfo);
|
||||
try {
|
||||
VolumeApiResult result = future.get();
|
||||
if (result.isFailed()) {
|
||||
s_logger.debug("Failed to create volume from snapshot:" + result.getResult());
|
||||
throw new CloudRuntimeException("Failed to create volume from snapshot:" + result.getResult());
|
||||
}
|
||||
return result.getVolume();
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("Failed to create volume from snapshot", e);
|
||||
throw new CloudRuntimeException("Failed to create volume from snapshot", e);
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.debug("Failed to create volume from snapshot", e);
|
||||
throw new CloudRuntimeException("Failed to create volume from snapshot", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing volume", async = true)
|
||||
|
||||
@ -31,7 +31,6 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
|
||||
@ -183,7 +182,6 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { TemplateManager.class, TemplateApiService.class })
|
||||
public class TemplateManagerImpl extends ManagerBase implements TemplateManager, TemplateApiService {
|
||||
private final static Logger s_logger = Logger.getLogger(TemplateManagerImpl.class);
|
||||
|
||||
@ -54,6 +54,7 @@ import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.lb.LoadBalancingRulesService;
|
||||
import com.cloud.network.rules.FirewallRule.State;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
@ -89,6 +90,8 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A
|
||||
@Inject NetworkOrchestrationService _ntwkMgr;
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
@Inject
|
||||
LoadBalancingRulesService _lbService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -362,7 +365,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A
|
||||
|
||||
@Override
|
||||
public boolean deleteApplicationLoadBalancer(long id) {
|
||||
return _lbMgr.deleteLoadBalancerRule(id, true);
|
||||
return _lbService.deleteLoadBalancerRule(id, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,69 +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.network;
|
||||
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
|
||||
import com.cloud.network.element.DhcpServiceProvider;
|
||||
import com.cloud.network.element.IpDeployer;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
||||
|
||||
@Ignore("Requires database to be set up")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="classpath:/testContext.xml")
|
||||
//@ComponentSetup(managerName="management-server", setupXml="network-mgr-component.xml")
|
||||
public class NetworkManagerTest {
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkManagerTest.class);
|
||||
@Inject NetworkOrchestrationService _networkMgr;
|
||||
|
||||
@Test
|
||||
public void testInjected() {
|
||||
NetworkManagerImpl networkMgr = (NetworkManagerImpl)_networkMgr;
|
||||
Assert.assertTrue(networkMgr._ipDeployers.iterator().hasNext());
|
||||
Assert.assertTrue(networkMgr._networkElements.iterator().hasNext());
|
||||
Assert.assertTrue(networkMgr._dhcpProviders.iterator().hasNext());
|
||||
Assert.assertNotNull(networkMgr._networkModel);
|
||||
|
||||
Assert.assertNotNull(AdapterBase.getAdapterByName(networkMgr._ipDeployers, "VirtualRouter"));
|
||||
Assert.assertNotNull(AdapterBase.getAdapterByName(networkMgr._ipDeployers, "VpcVirtualRouter"));
|
||||
|
||||
Assert.assertNotNull(AdapterBase.getAdapterByName(networkMgr._dhcpProviders, "VirtualRouter"));
|
||||
Assert.assertNotNull(AdapterBase.getAdapterByName(networkMgr._dhcpProviders, "VpcVirtualRouter"));
|
||||
|
||||
|
||||
Assert.assertTrue(AdapterBase.getAdapterByName(networkMgr._ipDeployers, "VirtualRouter") instanceof IpDeployer);
|
||||
Assert.assertTrue(AdapterBase.getAdapterByName(networkMgr._dhcpProviders, "VirtualRouter") instanceof DhcpServiceProvider);
|
||||
|
||||
s_logger.info("Done testing injection of network manager's network elements");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,7 +19,6 @@ package com.cloud.resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -36,10 +35,8 @@ import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
|
||||
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodCluster;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
@ -51,11 +48,8 @@ import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.resource.ResourceState.Event;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
||||
@ -430,16 +424,6 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.resource.ResourceManager#findPod(com.cloud.template.VirtualMachineTemplate, com.cloud.service.ServiceOfferingVO, com.cloud.dc.DataCenterVO, long, java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public Pair<Pod, Long> findPod(VirtualMachineTemplate template, ServiceOffering offering, DataCenter dc,
|
||||
long accountId, Set<Long> avoids) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.resource.ResourceManager#getHostStatistics(long)
|
||||
*/
|
||||
|
||||
@ -52,6 +52,7 @@ import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.lb.LoadBalancingRulesService;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.user.AccountManager;
|
||||
@ -80,6 +81,8 @@ public class ApplicationLoadBalancerTest extends TestCase{
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject FirewallRulesDao _firewallDao;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
@Inject
|
||||
LoadBalancingRulesService _lbService;
|
||||
|
||||
|
||||
public static long existingLbId = 1L;
|
||||
@ -105,8 +108,8 @@ public class ApplicationLoadBalancerTest extends TestCase{
|
||||
Mockito.when(_lbDao.findById(2L)).thenReturn(null);
|
||||
|
||||
//mockito for .deleteApplicationLoadBalancer tests
|
||||
Mockito.when(_lbMgr.deleteLoadBalancerRule(existingLbId, true)).thenReturn(true);
|
||||
Mockito.when(_lbMgr.deleteLoadBalancerRule(nonExistingLbId, true)).thenReturn(false);
|
||||
Mockito.when(_lbService.deleteLoadBalancerRule(existingLbId, true)).thenReturn(true);
|
||||
Mockito.when(_lbService.deleteLoadBalancerRule(nonExistingLbId, true)).thenReturn(false);
|
||||
|
||||
//mockito for .createApplicationLoadBalancer tests
|
||||
NetworkVO guestNetwork = new NetworkVO(TrafficType.Guest, null, null, 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user