cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [44/50] [abbrv] Merged master to vmsync
Date Tue, 14 May 2013 00:43:07 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --cc server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index 8e97788,dd51e74..8a5e3ae
--- a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@@ -17,36 -17,89 +17,86 @@@
  
  package com.cloud.vm;
  
++import static org.mockito.Matchers.any;
++import static org.mockito.Matchers.anyLong;
++import static org.mockito.Matchers.isA;
++import static org.mockito.Mockito.doNothing;
++import static org.mockito.Mockito.mock;
++import static org.mockito.Mockito.when;
++
++import java.util.HashMap;
++import java.util.Iterator;
++import java.util.List;
++import java.util.Map;
++
++import org.junit.Before;
++import org.junit.Test;
++import org.mockito.Mock;
++import org.mockito.MockitoAnnotations;
++import org.mockito.Spy;
++
++import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
++import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
++import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
++
  import com.cloud.agent.AgentManager;
  import com.cloud.agent.api.Answer;
 -import com.cloud.agent.api.ScaleVmAnswer;
 -import com.cloud.agent.api.ScaleVmCommand;
 -import com.cloud.capacity.CapacityManager;
 -import com.cloud.configuration.ConfigurationManager;
 -import com.cloud.configuration.dao.ConfigurationDao;
 -import com.cloud.deploy.DeployDestination;
 -import com.cloud.host.HostVO;
 -import com.cloud.host.dao.HostDao;
 -import com.cloud.service.ServiceOfferingVO;
 -import com.cloud.storage.VMTemplateVO;
 -import com.cloud.storage.VolumeManager;
 -import com.cloud.storage.VolumeVO;
 -import com.cloud.agent.api.PrepareForMigrationAnswer;
 -import com.cloud.agent.api.PrepareForMigrationCommand;
++import com.cloud.agent.api.CheckVirtualMachineAnswer;
++import com.cloud.agent.api.CheckVirtualMachineCommand;
+ import com.cloud.agent.api.MigrateWithStorageAnswer;
+ import com.cloud.agent.api.MigrateWithStorageCommand;
++import com.cloud.agent.api.MigrateWithStorageCompleteAnswer;
++import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
+ import com.cloud.agent.api.MigrateWithStorageReceiveAnswer;
+ import com.cloud.agent.api.MigrateWithStorageReceiveCommand;
+ import com.cloud.agent.api.MigrateWithStorageSendAnswer;
+ import com.cloud.agent.api.MigrateWithStorageSendCommand;
 -import com.cloud.agent.api.MigrateWithStorageCompleteAnswer;
 -import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
 -import com.cloud.agent.api.CheckVirtualMachineAnswer;
 -import com.cloud.agent.api.CheckVirtualMachineCommand;
++import com.cloud.agent.api.PrepareForMigrationAnswer;
++import com.cloud.agent.api.PrepareForMigrationCommand;
 +import com.cloud.agent.api.ScaleVmAnswer;
 +import com.cloud.agent.api.ScaleVmCommand;
  import com.cloud.capacity.CapacityManager;
  import com.cloud.configuration.ConfigurationManager;
  import com.cloud.configuration.dao.ConfigurationDao;
+ import com.cloud.dc.dao.ClusterDao;
+ import com.cloud.dc.dao.DataCenterDao;
+ import com.cloud.dc.dao.HostPodDao;
 +import com.cloud.deploy.DeployDestination;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.ManagementServerException;
++import com.cloud.exception.OperationTimedoutException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.exception.VirtualMachineMigrationException;
 -import com.cloud.exception.OperationTimedoutException;
  import com.cloud.host.HostVO;
  import com.cloud.host.dao.HostDao;
++import com.cloud.hypervisor.Hypervisor.HypervisorType;
+ import com.cloud.hypervisor.HypervisorGuru;
+ import com.cloud.hypervisor.HypervisorGuruManager;
 -import com.cloud.hypervisor.Hypervisor.HypervisorType;
+ import com.cloud.network.NetworkManager;
 +import com.cloud.service.ServiceOfferingVO;
+ import com.cloud.storage.DiskOfferingVO;
+ import com.cloud.storage.StoragePoolHostVO;
 +import com.cloud.storage.VMTemplateVO;
  import com.cloud.storage.VolumeManager;
  import com.cloud.storage.VolumeVO;
+ import com.cloud.storage.dao.DiskOfferingDao;
+ import com.cloud.storage.dao.StoragePoolHostDao;
  import com.cloud.storage.dao.VMTemplateDao;
  import com.cloud.storage.dao.VolumeDao;
--import com.cloud.user.*;
++import com.cloud.user.Account;
++import com.cloud.user.AccountManager;
++import com.cloud.user.AccountVO;
++import com.cloud.user.UserVO;
  import com.cloud.user.dao.AccountDao;
  import com.cloud.user.dao.UserDao;
 -import com.cloud.utils.exception.CloudRuntimeException;
 -import com.cloud.vm.dao.UserVmDao;
 -import com.cloud.vm.dao.VMInstanceDao;
 -import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
 -import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
+ import com.cloud.utils.Pair;
  import com.cloud.utils.exception.CloudRuntimeException;
++import com.cloud.vm.VirtualMachine.Event;
++import com.cloud.vm.VirtualMachine.PowerState;
++import com.cloud.vm.VirtualMachine.State;
  import com.cloud.vm.dao.UserVmDao;
  import com.cloud.vm.dao.VMInstanceDao;
- import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
- import org.junit.Test;
- import org.junit.Before;
- import org.mockito.Mock;
- import org.mockito.MockitoAnnotations;
- import org.mockito.Spy;
- import static org.mockito.Mockito.*;
- import java.util.List;
+ import com.cloud.vm.snapshot.VMSnapshotManager;
 -import com.cloud.vm.VirtualMachine.Event;
 -import com.cloud.vm.VirtualMachine.State;
 -
 -import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 -import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 -
 -import org.junit.Test;
 -import org.junit.Before;
 -import org.mockito.Mock;
 -import org.mockito.MockitoAnnotations;
 -import org.mockito.Spy;
 -import static org.mockito.Matchers.anyLong;
 -import static org.mockito.Mockito.*;
 -
 -import java.lang.reflect.Field;
 -import java.util.List;
 -import java.util.Map;
 -import java.util.HashMap;
 -import java.util.Iterator;
  
  public class VirtualMachineManagerImplTest {
  
@@@ -116,10 -187,18 +184,20 @@@
              _vmMgr._capacityMgr = _capacityMgr;
              _vmMgr._hostDao = _hostDao;
              _vmMgr._nodeId = 1L;
- /*            
++/*
              _vmMgr._workDao = _workDao;
- */  
++*/
              _vmMgr._agentMgr = _agentMgr;
+             _vmMgr._podDao = _podDao;
+             _vmMgr._clusterDao = _clusterDao;
+             _vmMgr._dcDao = _dcDao;
+             _vmMgr._diskOfferingDao = _diskOfferingDao;
+             _vmMgr._storagePoolDao = _storagePoolDao;
+             _vmMgr._poolHostDao= _poolHostDao;
+             _vmMgr._networkMgr = _networkMgr;
+             _vmMgr._hvGuruMgr = _hvGuruMgr;
+             _vmMgr._vmSnapshotMgr = _vmSnapshotMgr;
+             _vmMgr._vmDao = _vmInstanceDao;
  
              when(_vmMock.getId()).thenReturn(314l);
              when(_vmInstance.getId()).thenReturn(1L);
@@@ -202,5 -281,155 +280,155 @@@
          return serviceOffering;
      }
  
+     private void initializeMockConfigForMigratingVmWithVolumes() throws OperationTimedoutException,
+         ResourceUnavailableException {
+ 
+         // Mock the source and destination hosts.
+         when(_srcHostMock.getId()).thenReturn(5L);
+         when(_destHostMock.getId()).thenReturn(6L);
+         when(_hostDao.findById(5L)).thenReturn(_srcHostMock);
+         when(_hostDao.findById(6L)).thenReturn(_destHostMock);
+ 
+         // Mock the vm being migrated.
+         when(_vmMock.getId()).thenReturn(1L);
+         when(_vmMock.getHypervisorType()).thenReturn(HypervisorType.XenServer);
+         when(_vmMock.getState()).thenReturn(State.Running).thenReturn(State.Running).thenReturn(State.Migrating)
+             .thenReturn(State.Migrating);
+         when(_vmMock.getHostId()).thenReturn(5L);
+         when(_vmInstance.getId()).thenReturn(1L);
+         when(_vmInstance.getServiceOfferingId()).thenReturn(2L);
+         when(_vmInstance.getInstanceName()).thenReturn("myVm");
+         when(_vmInstance.getHostId()).thenReturn(5L);
+         when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
+         when(_vmInstance.getState()).thenReturn(State.Running).thenReturn(State.Running).thenReturn(State.Migrating)
+             .thenReturn(State.Migrating);
+ 
+         // Mock the work item.
+         when(_workDao.persist(any(ItWorkVO.class))).thenReturn(_work);
+         when(_workDao.update("1", _work)).thenReturn(true);
+         when(_work.getId()).thenReturn("1");
+         doNothing().when(_work).setStep(ItWorkVO.Step.Done);
+ 
+         // Mock the vm guru and the user vm object that gets returned.
+         _vmMgr._vmGurus = new HashMap<VirtualMachine.Type, VirtualMachineGuru<? extends
VMInstanceVO>>();
+         UserVmManagerImpl userVmManager = mock(UserVmManagerImpl.class);
+         _vmMgr.registerGuru(VirtualMachine.Type.User, userVmManager);
+         when(userVmManager.findById(anyLong())).thenReturn(_vmMock);
+ 
+         // Mock the iteration over all the volumes of an instance.
+         Iterator<VolumeVO> volumeIterator = mock(Iterator.class);
+         when(_volsDao.findUsableVolumesForInstance(anyLong())).thenReturn(_rootVols);
+         when(_rootVols.iterator()).thenReturn(volumeIterator);
+         when(volumeIterator.hasNext()).thenReturn(true, false);
+         when(volumeIterator.next()).thenReturn(_volumeMock);
+ 
+         // Mock the disk offering and pool objects for a volume.
+         when(_volumeMock.getDiskOfferingId()).thenReturn(5L);
+         when(_volumeMock.getPoolId()).thenReturn(200L);
+         when(_diskOfferingDao.findById(anyLong())).thenReturn(_diskOfferingMock);
+         when(_storagePoolDao.findById(anyLong())).thenReturn(_srcStoragePoolMock);
+ 
+         // Mock the volume to pool mapping.
+         when(_volumeToPoolMock.get(_volumeMock)).thenReturn(_destStoragePoolMock);
+         when(_destStoragePoolMock.getId()).thenReturn(201L);
+         when(_srcStoragePoolMock.getId()).thenReturn(200L);
+         when(_destStoragePoolMock.isLocal()).thenReturn(false);
+         when(_diskOfferingMock.getUseLocalStorage()).thenReturn(false);
+         when(_poolHostDao.findByPoolHost(anyLong(), anyLong())).thenReturn(mock(StoragePoolHostVO.class));
  
+         // Mock hypervisor guru.
+         HypervisorGuru guruMock = mock(HypervisorGuru.class);
+         when(_hvGuruMgr.getGuru(HypervisorType.XenServer)).thenReturn(guruMock);
+ 
+         when(_srcHostMock.getClusterId()).thenReturn(3L);
+         when(_destHostMock.getClusterId()).thenReturn(3L);
+ 
+         // Mock the commands and answers to the agent.
+         PrepareForMigrationAnswer prepAnswerMock = mock(PrepareForMigrationAnswer.class);
+         when(prepAnswerMock.getResult()).thenReturn(true);
+         when(_agentMgr.send(anyLong(), isA(PrepareForMigrationCommand.class))).thenReturn(prepAnswerMock);
+ 
+         MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
+         when(migAnswerMock.getResult()).thenReturn(true);
+         when(_agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
+ 
+         MigrateWithStorageReceiveAnswer migRecAnswerMock = mock(MigrateWithStorageReceiveAnswer.class);
+         when(migRecAnswerMock.getResult()).thenReturn(true);
+         when(_agentMgr.send(anyLong(), isA(MigrateWithStorageReceiveCommand.class))).thenReturn(migRecAnswerMock);
+ 
+         MigrateWithStorageSendAnswer migSendAnswerMock = mock(MigrateWithStorageSendAnswer.class);
+         when(migSendAnswerMock.getResult()).thenReturn(true);
+         when(_agentMgr.send(anyLong(), isA(MigrateWithStorageSendCommand.class))).thenReturn(migSendAnswerMock);
+ 
+         MigrateWithStorageCompleteAnswer migCompleteAnswerMock = mock(MigrateWithStorageCompleteAnswer.class);
+         when(migCompleteAnswerMock.getResult()).thenReturn(true);
+         when(_agentMgr.send(anyLong(), isA(MigrateWithStorageCompleteCommand.class))).thenReturn(migCompleteAnswerMock);
+ 
+         CheckVirtualMachineAnswer checkVmAnswerMock = mock(CheckVirtualMachineAnswer.class);
+         when(checkVmAnswerMock.getResult()).thenReturn(true);
 -        when(checkVmAnswerMock.getState()).thenReturn(State.Running);
++        when(checkVmAnswerMock.getState()).thenReturn(PowerState.PowerOn);
+         when(_agentMgr.send(anyLong(), isA(CheckVirtualMachineCommand.class))).thenReturn(checkVmAnswerMock);
+ 
+         // Mock the state transitions of vm.
+         Pair<Long, Long> opaqueMock = new Pair<Long, Long> (_vmMock.getHostId(),
_destHostMock.getId());
+         when(_vmSnapshotMgr.hasActiveVMSnapshotTasks(anyLong())).thenReturn(false);
+         when(_vmInstanceDao.updateState(State.Running, Event.MigrationRequested, State.Migrating,
_vmMock, opaqueMock))
+             .thenReturn(true);
+         when(_vmInstanceDao.updateState(State.Migrating, Event.OperationSucceeded, State.Running,
_vmMock, opaqueMock))
+             .thenReturn(true);
+     }
+ 
+     // Check migration of a vm with its volumes within a cluster.
+     @Test
+     public void testMigrateWithVolumeWithinCluster() throws ResourceUnavailableException,
ConcurrentOperationException,
+         ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException
{
+ 
+         initializeMockConfigForMigratingVmWithVolumes();
+         when(_srcHostMock.getClusterId()).thenReturn(3L);
+         when(_destHostMock.getClusterId()).thenReturn(3L);
+ 
+         _vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(),
_volumeToPoolMock);
+     }
+ 
+     // Check migration of a vm with its volumes across a cluster.
+     @Test
+     public void testMigrateWithVolumeAcrossCluster() throws ResourceUnavailableException,
ConcurrentOperationException,
+         ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException
{
+ 
+         initializeMockConfigForMigratingVmWithVolumes();
+         when(_srcHostMock.getClusterId()).thenReturn(3L);
+         when(_destHostMock.getClusterId()).thenReturn(4L);
+ 
+         _vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(),
_volumeToPoolMock);
+     }
+ 
+     // Check migration of a vm fails when src and destination pool are not of same type;
that is, one is shared and
+     // other is local.
+     @Test(expected=CloudRuntimeException.class)
+     public void testMigrateWithVolumeFail1() throws ResourceUnavailableException, ConcurrentOperationException,
+         ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException
{
+ 
+         initializeMockConfigForMigratingVmWithVolumes();
+         when(_srcHostMock.getClusterId()).thenReturn(3L);
+         when(_destHostMock.getClusterId()).thenReturn(3L);
+ 
+         when(_destStoragePoolMock.isLocal()).thenReturn(true);
+         when(_diskOfferingMock.getUseLocalStorage()).thenReturn(false);
+ 
+         _vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(),
_volumeToPoolMock);
+     }
+ 
+     // Check migration of a vm fails when vm is not in Running state.
+     @Test(expected=ConcurrentOperationException.class)
+     public void testMigrateWithVolumeFail2() throws ResourceUnavailableException, ConcurrentOperationException,
+         ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException
{
+ 
+         initializeMockConfigForMigratingVmWithVolumes();
+         when(_srcHostMock.getClusterId()).thenReturn(3L);
+         when(_destHostMock.getClusterId()).thenReturn(3L);
+ 
+         when(_vmMock.getState()).thenReturn(State.Stopped);
+ 
+         _vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(),
_volumeToPoolMock);
+     }
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --cc server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
index c078e39,0000000..4f992d9
mode 100644,000000..100644
--- a/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
+++ b/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
@@@ -1,421 -1,0 +1,432 @@@
 +// 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.net.URI;
 +import java.util.Collection;
 +import java.util.List;
 +import java.util.Map;
 +
 +import javax.inject.Inject;
 +import javax.naming.ConfigurationException;
 +
- import org.apache.cloudstack.framework.messagebus.MessageBus;
 +import org.apache.log4j.Logger;
 +
++import org.apache.cloudstack.framework.messagebus.MessageBus;
++import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
++
 +import com.cloud.agent.api.to.NicTO;
 +import com.cloud.agent.api.to.VirtualMachineTO;
 +import com.cloud.async.AsyncJobConstants;
 +import com.cloud.async.AsyncJobExecutionContext;
 +import com.cloud.deploy.DeployDestination;
 +import com.cloud.deploy.DeploymentPlan;
 +import com.cloud.exception.AgentUnavailableException;
 +import com.cloud.exception.ConcurrentOperationException;
 +import com.cloud.exception.InsufficientCapacityException;
 +import com.cloud.exception.InsufficientServerCapacityException;
 +import com.cloud.exception.ManagementServerException;
 +import com.cloud.exception.OperationTimedoutException;
 +import com.cloud.exception.ResourceUnavailableException;
 +import com.cloud.exception.VirtualMachineMigrationException;
 +import com.cloud.hypervisor.Hypervisor.HypervisorType;
 +import com.cloud.network.Network;
 +import com.cloud.network.dao.NetworkVO;
 +import com.cloud.offering.ServiceOffering;
 +import com.cloud.service.ServiceOfferingVO;
 +import com.cloud.storage.DiskOfferingVO;
 +import com.cloud.storage.StoragePool;
 +import com.cloud.storage.VMTemplateVO;
++import com.cloud.storage.VolumeVO;
 +import com.cloud.user.Account;
 +import com.cloud.user.User;
 +import com.cloud.utils.Pair;
 +import com.cloud.utils.fsm.NoTransitionException;
 +import com.cloud.vm.VirtualMachine.Event;
 +import com.cloud.vm.VirtualMachine.Type;
 +import com.cloud.vm.VirtualMachineProfile.Param;
 +
 +public class VmWorkMockVirtualMachineManagerImpl implements VirtualMachineManager {
 +    private static final Logger s_logger = Logger.getLogger(VmWorkMockVirtualMachineManagerImpl.class);
 +	
 +	@Inject MessageBus _msgBus;
 +	
 +	@Override
 +	public String getName() {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public void setName(String name) {
 +		// TODO Auto-generated method stub
 +	}
 +
 +	@Override
 +	public void setConfigParams(Map<String, Object> params) {
 +		// TODO Auto-generated method stub
 +		
 +	}
 +
 +	@Override
 +	public Map<String, Object> getConfigParams() {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public int getRunLevel() {
 +		// TODO Auto-generated method stub
 +		return 0;
 +	}
 +
 +	@Override
 +	public void setRunLevel(int level) {
 +		// TODO Auto-generated method stub
 +		
 +	}
 +
 +	@Override
 +	public boolean configure(String name, Map<String, Object> params)
 +			throws ConfigurationException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public boolean start() {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public boolean stop() {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template,
 +			ServiceOfferingVO serviceOffering,
 +			Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
 +			List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
 +			List<Pair<NetworkVO, NicProfile>> networks,
 +			Map<Param, Object> params, DeploymentPlan plan,
 +			HypervisorType hyperType, Account owner)
 +			throws InsufficientCapacityException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template,
 +			ServiceOfferingVO serviceOffering, Long rootSize,
 +			Pair<DiskOfferingVO, Long> dataDiskOffering,
 +			List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan,
 +			HypervisorType hyperType, Account owner)
 +			throws InsufficientCapacityException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template,
 +			ServiceOfferingVO serviceOffering,
 +			List<Pair<NetworkVO, NicProfile>> networkProfiles,
 +			DeploymentPlan plan, HypervisorType hyperType, Account owner)
 +			throws InsufficientCapacityException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params,
 +			User caller, Account account) throws InsufficientCapacityException,
 +			ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params,
 +			User caller, Account account, DeploymentPlan planToDeploy)
 +			throws InsufficientCapacityException, ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean stop(T vm, User caller,
 +			Account account) throws ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean expunge(T vm, User caller,
 +			Account account) throws ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> void registerGuru(Type type,
 +			VirtualMachineGuru<T> guru) {
 +		// TODO Auto-generated method stub
 +		
 +	}
 +
 +	@Override
 +	public Collection<VirtualMachineGuru<? extends VMInstanceVO>> getRegisteredGurus()
{
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +	
++    @Override
 +    public <T extends VMInstanceVO> VirtualMachineGuru<T> getVmGuru(T vm) {
 +		// TODO Auto-generated method stub
 +    	return null;
 +    }
 +
 +	@Override
 +	public boolean stateTransitTo(VMInstanceVO vm, Event e, Long hostId)
 +			throws NoTransitionException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T advanceStart(T vm,
 +			Map<Param, Object> params, User caller, Account account)
 +			throws InsufficientCapacityException, ResourceUnavailableException,
 +			ConcurrentOperationException, OperationTimedoutException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T advanceStart(T vm,
 +			Map<Param, Object> params, User caller, Account account,
 +			DeploymentPlan planToDeploy) throws InsufficientCapacityException,
 +			ResourceUnavailableException, ConcurrentOperationException,
 +			OperationTimedoutException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced,
 +			User caller, Account account) throws ResourceUnavailableException,
 +			OperationTimedoutException, ConcurrentOperationException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller,
 +			Account account) throws ResourceUnavailableException,
 +			OperationTimedoutException, ConcurrentOperationException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean remove(T vm, User caller,
 +			Account account) {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> boolean destroy(T vm, User caller,
 +			Account account) throws AgentUnavailableException,
 +			OperationTimedoutException, ConcurrentOperationException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public boolean migrateAway(Type type, long vmid, long hostId)
 +			throws InsufficientServerCapacityException,
 +			VirtualMachineMigrationException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T migrate(T vm, long srcHostId,
 +			DeployDestination dest) throws ResourceUnavailableException,
 +			ConcurrentOperationException, ManagementServerException,
 +			VirtualMachineMigrationException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T reboot(T vm, Map<Param, Object> params,
 +			User caller, Account account) throws InsufficientCapacityException,
 +			ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T advanceReboot(T vm,
 +			Map<Param, Object> params, User caller, Account account)
 +			throws InsufficientCapacityException, ResourceUnavailableException,
 +			ConcurrentOperationException, OperationTimedoutException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public VMInstanceVO findByIdAndType(Type type, long vmId) {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public boolean isVirtualMachineUpgradable(VirtualMachine vm,
 +			ServiceOffering offering) {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public VMInstanceVO findById(long vmId) {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T storageMigration(T vm,
 +			StoragePool storagePoolId) {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public void checkIfCanUpgrade(VirtualMachine vmInstance,
 +			long newServiceOfferingId) {
 +		// TODO Auto-generated method stub
 +		
 +	}
 +
 +	@Override
 +	public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public NicProfile addVmToNetwork(VirtualMachine vm, Network network,
 +			NicProfile requested) throws ConcurrentOperationException,
 +			ResourceUnavailableException, InsufficientCapacityException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public boolean removeNicFromVm(VirtualMachine vm, NicVO nic)
 +			throws ConcurrentOperationException, ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public boolean removeVmFromNetwork(VirtualMachine vm, Network network,
 +			URI broadcastUri) throws ConcurrentOperationException,
 +			ResourceUnavailableException {
 +		// TODO Auto-generated method stub
 +		return false;
 +	}
 +
 +	@Override
 +	public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public VirtualMachineTO toVmTO(
 +			VirtualMachineProfile<? extends VMInstanceVO> profile) {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public VMInstanceVO reConfigureVm(VMInstanceVO vm,
 +			ServiceOffering newServiceOffering, boolean sameHost)
 +			throws ResourceUnavailableException, ConcurrentOperationException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public VMInstanceVO findHostAndMigrate(Type vmType, VMInstanceVO vm,
 +			Long newSvcOfferingId) throws InsufficientCapacityException,
 +			ConcurrentOperationException, ResourceUnavailableException,
 +			VirtualMachineMigrationException, ManagementServerException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +	public <T extends VMInstanceVO> T migrateForScale(T vm, long srcHostId,
 +			DeployDestination dest, Long newSvcOfferingId)
 +			throws ResourceUnavailableException, ConcurrentOperationException,
 +			ManagementServerException, VirtualMachineMigrationException {
 +		// TODO Auto-generated method stub
 +		return null;
 +	}
 +
 +	@Override
 +    public <T extends VMInstanceVO> T processVmStartWork(T vm, Map<VirtualMachineProfile.Param,
Object> params, User caller, Account account, DeploymentPlan planToDeploy)
 +            throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException
{
 +    	
 +		try {
 +			Thread.sleep(120000);
 +		} catch (InterruptedException e) {
 +		}
 +    	
 +    	return vm;
 +    }
 +
 +	int wakeupCount = 0;
 +	public void processVmStartWakeup() {
 +		s_logger.info("processVmStartWakeup. job-" + AsyncJobExecutionContext.getCurrentExecutionContext().getJob().getId());
 +		
 +		if(wakeupCount++ < 3) {
 +			AsyncJobExecutionContext.getCurrentExecutionContext().resetSyncSource();
 +		} else {
 +			AsyncJobExecutionContext.getCurrentExecutionContext().completeAsyncJob(AsyncJobConstants.STATUS_SUCCEEDED,
0, null);
 +		}
 +	}
 +	
 +	@Override
-     public <T extends VMInstanceVO> boolean processVmStopWork(T vm, boolean forced,
User user, Account account) 
++    public <T extends VMInstanceVO> boolean processVmStopWork(T vm, boolean forced,
User user, Account account)
 +        throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException
{
 +    	return true;
 +    }
++
++    @Override
++    public <T extends VMInstanceVO> T migrateWithStorage(T vm, long srcId, long destId,
Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException,
++            ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException
{
++        // TODO Auto-generated method stub
++        return null;
++    }
 +}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --cc setup/db/db/schema-410to420.sql
index 16f93b2,065b35c..75eec59
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@@ -391,83 -1116,65 +1116,132 @@@ CREATE VIEW `cloud`.`account_view` A
              and async_job.instance_type = 'Account'
              and async_job.job_status = 0;
  
- ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `id` bigint unsigned NOT NULL UNIQUE
AUTO_INCREMENT COMMENT 'id';
- ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `uuid` varchar(40) UNIQUE;
  
- -- START: support for LXC
 -
 + 
- INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version,
max_guests_limit, security_group_enabled) VALUES ('LXC', 'default', 50, 1);
- ALTER TABLE `cloud`.`physical_network_traffic_types` ADD COLUMN `lxc_network_label` varchar(255)
DEFAULT 'cloudbr0' COMMENT 'The network name label of the physical device dedicated to this
traffic on a LXC host';
+ ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address` varchar(40) COMMENT
'source ip address for the load balancer rule';
+ ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address_network_id` bigint
unsigned COMMENT 'the id of the network where source ip belongs to';
+ ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `scheme` varchar(40) NOT NULL COMMENT
'load balancer scheme; can be Internal or Public';
+ UPDATE `cloud`.`load_balancing_rules` SET `scheme`='Public';
 + 
- UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC' WHERE name='hypervisor.list';
 + 
- INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits,
account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones,
hypervisor_type)
-      VALUES (10, 'routing-10', 'SystemVM Template (LXC)', 0, now(), 'SYSTEM', 0, 64, 1,
'http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2', '2755de1f9ef2ce4d6f2bee2efbb4da92',
0, 'SystemVM Template (LXC)', 'QCOW2', 15, 0, 1, 'LXC');
 +
 +-- END: support for LXC
 +
 +ALTER TABLE `cloud`.`async_job` DROP COLUMN `session_key`;
 +ALTER TABLE `cloud`.`async_job` DROP COLUMN `job_cmd_originator`;
 +ALTER TABLE `cloud`.`async_job` DROP COLUMN `callback_type`;
 +ALTER TABLE `cloud`.`async_job` DROP COLUMN `callback_address`;
 +
 +ALTER TABLE `cloud`.`async_job` ADD COLUMN `job_type` VARCHAR(32);
 +ALTER TABLE `cloud`.`async_job` ADD COLUMN `job_dispatcher` VARCHAR(64);
 +ALTER TABLE `cloud`.`async_job` ADD COLUMN `job_executing_msid` bigint;
 +ALTER TABLE `cloud`.`async_job` ADD COLUMN `job_pending_signals` int(10) NOT NULL DEFAULT
0;
  
 +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `power_state` VARCHAR(74) DEFAULT 'PowerUnknown';
 +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `power_state_update_time` DATETIME;
 +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `power_state_update_count` INT DEFAULT 0;
 +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `power_host` bigint unsigned;
 +ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__power_host` FOREIGN KEY
(`power_host`) REFERENCES `cloud`.`host`(`id`);
  
 +CREATE TABLE `cloud`.`vm_work_job` (
 +  `id` bigint unsigned UNIQUE NOT NULL,
 +  `step` char(32) NOT NULL COMMENT 'state',
 +  `vm_type` char(32) NOT NULL COMMENT 'type of vm',
 +  `vm_instance_id` bigint unsigned NOT NULL COMMENT 'vm instance',
 +  PRIMARY KEY (`id`),
 +  CONSTRAINT `fk_vm_work_job__instance_id` FOREIGN KEY (`vm_instance_id`) REFERENCES `vm_instance`(`id`)
ON DELETE CASCADE,
 +  INDEX `i_vm_work_job__vm`(`vm_type`, `vm_instance_id`),
 +  INDEX `i_vm_work_job__step`(`step`)
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 +
 +CREATE TABLE `cloud`.`async_job_journal` (
 +  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
 +  `job_id` bigint unsigned NOT NULL,
 +  `journal_type` varchar(32),
 +  `journal_text` varchar(1024) COMMENT 'journal descriptive informaton',
 +  `journal_obj` varchar(1024) COMMENT 'journal strutural information, JSON encoded object',
 +  `created` datetime NOT NULL COMMENT 'date created',
 +  PRIMARY KEY (`id`),
 +  CONSTRAINT `fk_async_job_journal__job_id` FOREIGN KEY (`job_id`) REFERENCES `async_job`(`id`)
ON DELETE CASCADE
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 +
 +CREATE TABLE `cloud`.`async_job_join_map` (
 +  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
 +  `job_id` bigint unsigned NOT NULL,
 +  `join_job_id` bigint unsigned NOT NULL,
 +  `join_status` int NOT NULL,
 +  `join_result` varchar(1024),
 +  `join_msid` bigint,
 +  `complete_msid` bigint,
 +  `sync_source_id` bigint COMMENT 'upper-level job sync source info before join',
 +  `wakeup_handler` varchar(64),
 +  `wakeup_dispatcher` varchar(64),
 +  `wakeup_interval` bigint NOT NULL DEFAULT 3000 COMMENT 'wakeup interval in seconds',
 +  `created` datetime NOT NULL,
 +  `last_updated` datetime,
 +  `next_wakeup` datetime,
 +  `expiration` datetime,
 +  PRIMARY KEY (`id`),
 +  CONSTRAINT `fk_async_job_join_map__job_id` FOREIGN KEY (`job_id`) REFERENCES `async_job`(`id`)
ON DELETE CASCADE,
 +  CONSTRAINT `fk_async_job_join_map__join_job_id` FOREIGN KEY (`join_job_id`) REFERENCES
`async_job`(`id`),
 +  CONSTRAINT `fk_async_job_join_map__join` UNIQUE (`job_id`, `join_job_id`),
 +  INDEX `i_async_job_join_map__join_job_id`(`join_job_id`),
 +  INDEX `i_async_job_join_map__created`(`created`),
 +  INDEX `i_async_job_join_map__last_updated`(`last_updated`),
 +  INDEX `i_async_job_join_map__next_wakeup`(`next_wakeup`),
 +  INDEX `i_async_job_join_map__expiration`(`expiration`)
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
+ -- Add details talbe for the network offering
+ CREATE TABLE `cloud`.`network_offering_details` (
+   `id` bigint unsigned NOT NULL auto_increment,
+   `network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id',
+   `name` varchar(255) NOT NULL,
+   `value` varchar(1024) NOT NULL,
+   PRIMARY KEY (`id`),
+   CONSTRAINT `fk_network_offering_details__network_offering_id` FOREIGN KEY `fk_network_offering_details__network_offering_id`(`network_offering_id`)
REFERENCES `network_offerings`(`id`) ON DELETE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ 
+ -- Change the constraint for the network service map table. Now we support multiple provider
for the same service
+ ALTER TABLE `cloud`.`ntwk_service_map` DROP FOREIGN KEY `fk_ntwk_service_map__network_id`;
+ ALTER TABLE `cloud`.`ntwk_service_map` DROP INDEX `network_id`;
+ 
+ ALTER TABLE `cloud`.`ntwk_service_map` ADD UNIQUE `network_id` (`network_id`,`service`,`provider`);
+ ALTER TABLE `cloud`.`ntwk_service_map` ADD  CONSTRAINT `fk_ntwk_service_map__network_id`
FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
+ 
+ 
+ ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `internal_lb` int(1) unsigned NOT NULL
DEFAULT '0' COMMENT 'true if the network offering supports Internal lb service';
+ ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `public_lb` int(1) unsigned NOT NULL
DEFAULT '0' COMMENT 'true if the network offering supports Public lb service';
+ UPDATE `cloud`.`network_offerings` SET public_lb=1 where id IN (SELECT DISTINCT network_offering_id
FROM `cloud`.`ntwk_offering_service_map` WHERE service='Lb');
+ 
+ 
+ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager',
'internallbvm.service.offering', null, 'Uuid of the service offering used by internal lb vm;
if NULL - default system internal lb offering will be used');
+ 
+ 
+ alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned
NOT NULL;
+ ALTER TABLE `cloud`.`data_center_details` MODIFY value varchar(1024);
+ ALTER TABLE `cloud`.`cluster_details` MODIFY value varchar(255);
+ ALTER TABLE `cloud`.`storage_pool_details` MODIFY value varchar(255);
+ ALTER TABLE `cloud`.`account_details` MODIFY value varchar(255);
+ 
+ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server',
'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet
API server can be contacted (if using Midonet)');
+ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server',
'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of
the Midonet provider router (if using Midonet)');
+ 
+ alter table cloud.vpc_gateways add column source_nat boolean default false;
+ alter table cloud.private_ip_address add column source_nat boolean default false;
+ 
+ CREATE TABLE `cloud`.`account_vnet_map` (
+   `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
+   `uuid` varchar(255) UNIQUE,
+   `vnet_range` varchar(255) NOT NULL COMMENT 'dedicated guest vlan range',
+   `account_id` bigint unsigned NOT NULL COMMENT 'account id. foreign key to account table',
+   `physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network id. foreign key
to the the physical network table',
+   PRIMARY KEY (`id`),
+   CONSTRAINT `fk_account_vnet_map__physical_network_id` FOREIGN KEY (`physical_network_id`)
REFERENCES `physical_network` (`id`) ON DELETE CASCADE,
+   INDEX `i_account_vnet_map__physical_network_id`(`physical_network_id`),
+   CONSTRAINT `fk_account_vnet_map__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`
(`id`) ON DELETE CASCADE,
+   INDEX `i_account_vnet_map__account_id`(`account_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ 
+ ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD COLUMN account_vnet_map_id bigint unsigned;
+ ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD CONSTRAINT `fk_op_dc_vnet_alloc__account_vnet_map_id`
FOREIGN KEY `fk_op_dc_vnet_alloc__account_vnet_map_id` (`account_vnet_map_id`) REFERENCES
`account_vnet_map` (`id`);


Mime
View raw message