Search in sources :

Example 16 with VirtualMachineProfile

use of com.cloud.vm.VirtualMachineProfile in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
    final VirtualRouter router = userdata.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final VirtualMachineProfile profile = userdata.getProfile();
    final NicVO nicVo = userdata.getNicVo();
    final UserVmVO userVM = userdata.getUserVM();
    final DeployDestination destination = userdata.getDestination();
    if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
        return _networkGeneralHelper.sendCommandsToRouter(router, commands);
    }
    return true;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 17 with VirtualMachineProfile

use of com.cloud.vm.VirtualMachineProfile in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final PasswordToRouterRules passwd) throws ResourceUnavailableException {
    final VirtualRouter router = passwd.getRouter();
    final NicVO nicVo = passwd.getNicVo();
    final VirtualMachineProfile profile = passwd.getProfile();
    final Commands cmds = new Commands(Command.OnError.Stop);
    _commandSetupHelper.createPasswordCommand(router, profile, nicVo, cmds);
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 18 with VirtualMachineProfile

use of com.cloud.vm.VirtualMachineProfile in project cloudstack by apache.

the class NuageVspGuestNetworkGuruTest method testDeallocate.

@Test
public void testDeallocate() throws Exception {
    final NetworkVO network = mock(NetworkVO.class);
    when(network.getId()).thenReturn(NETWORK_ID);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getVpcId()).thenReturn(null);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
    final NetworkOfferingVO offering = mock(NetworkOfferingVO.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(offering);
    final DomainVO domain = mock(DomainVO.class);
    when(domain.getUuid()).thenReturn("aaaaaa");
    when(_domainDao.findById(NETWORK_ID)).thenReturn(domain);
    final NicVO nic = mock(NicVO.class);
    when(nic.getId()).thenReturn(NETWORK_ID);
    when(nic.getIPv4Address()).thenReturn("10.10.10.10");
    when(nic.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
    when(_nicDao.findById(NETWORK_ID)).thenReturn(nic);
    final NicProfile nicProfile = mock(NicProfile.class);
    when(nicProfile.getId()).thenReturn(NETWORK_ID);
    when(nicProfile.getIPv4Address()).thenReturn("10.10.10.10");
    when(nicProfile.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
    final VirtualMachine vm = mock(VirtualMachine.class);
    when(vm.getType()).thenReturn(VirtualMachine.Type.User);
    when(vm.getState()).thenReturn(VirtualMachine.State.Expunging);
    final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
    when(vmProfile.getUuid()).thenReturn("aaaaaa");
    when(vmProfile.getInstanceName()).thenReturn("Test-VM");
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    _nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile);
}
Also used : DomainVO(com.cloud.domain.DomainVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) NicProfile(com.cloud.vm.NicProfile) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualMachine(com.cloud.vm.VirtualMachine) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 19 with VirtualMachineProfile

use of com.cloud.vm.VirtualMachineProfile in project cloudstack by apache.

the class GloboDnsElementTest method testReleaseMethodCallResource.

@Test
public void testReleaseMethodCallResource() throws Exception {
    Network network = mock(Network.class);
    when(network.getDataCenterId()).thenReturn(zoneId);
    when(network.getId()).thenReturn(1l);
    NicProfile nic = new NicProfile();
    nic.setIPv4Address("10.11.12.13");
    VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
    when(vm.getHostName()).thenReturn("vm-name");
    when(vm.getType()).thenReturn(VirtualMachine.Type.User);
    DataCenterVO dataCenterVO = mock(DataCenterVO.class);
    when(dataCenterVO.getId()).thenReturn(zoneId);
    when(_datacenterDao.findById(zoneId)).thenReturn(dataCenterVO);
    ReservationContext context = new ReservationContextImpl(null, null, user);
    HostVO hostVO = mock(HostVO.class);
    when(hostVO.getId()).thenReturn(globoDnsHostId);
    when(_hostDao.findByTypeNameAndZoneId(eq(zoneId), eq(Provider.GloboDns.getName()), eq(Type.L2Networking))).thenReturn(hostVO);
    when(_agentMgr.easySend(eq(globoDnsHostId), isA(RemoveRecordCommand.class))).then(new org.mockito.stubbing.Answer<Answer>() {

        @Override
        public Answer answer(InvocationOnMock invocation) throws Throwable {
            Command cmd = (Command) invocation.getArguments()[1];
            return new Answer(cmd);
        }
    });
    _globodnsElement.release(network, nic, vm, context);
    verify(_agentMgr, times(1)).easySend(eq(globoDnsHostId), isA(RemoveRecordCommand.class));
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) RemoveRecordCommand(com.globo.globodns.cloudstack.commands.RemoveRecordCommand) NicProfile(com.cloud.vm.NicProfile) ReservationContextImpl(com.cloud.vm.ReservationContextImpl) HostVO(com.cloud.host.HostVO) ReservationContext(com.cloud.vm.ReservationContext) Answer(com.cloud.agent.api.Answer) RemoveRecordCommand(com.globo.globodns.cloudstack.commands.RemoveRecordCommand) CreateOrUpdateRecordAndReverseCommand(com.globo.globodns.cloudstack.commands.CreateOrUpdateRecordAndReverseCommand) Command(com.cloud.agent.api.Command) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Network(com.cloud.network.Network) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) Test(org.junit.Test)

Example 20 with VirtualMachineProfile

use of com.cloud.vm.VirtualMachineProfile in project cloudstack by apache.

the class ElasticLoadBalancerManagerImplTest method testFinalizeStartWhenCmdsAnswerIsNotNullButAnswerResultIsFalse.

@Test
public void testFinalizeStartWhenCmdsAnswerIsNotNullButAnswerResultIsFalse() throws Exception {
    CheckSshAnswer answerMock = mock(CheckSshAnswer.class);
    when(answerMock.getResult()).thenReturn(false);
    VirtualMachineProfile profileMock = mock(VirtualMachineProfile.class);
    long hostId = 1L;
    Commands cmds = mock(Commands.class);
    when(cmds.getAnswer("checkSsh")).thenReturn(answerMock);
    ReservationContext context = mock(ReservationContext.class);
    boolean expected = false;
    boolean actual = elasticLoadBalancerManagerImpl.finalizeStart(profileMock, hostId, cmds, context);
    assertEquals(expected, actual);
}
Also used : CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Aggregations

VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)38 Test (org.junit.Test)23 DataCenterVO (com.cloud.dc.DataCenterVO)12 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)11 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)11 StoragePool (com.cloud.storage.StoragePool)11 DiskProfile (com.cloud.vm.DiskProfile)10 NicProfile (com.cloud.vm.NicProfile)10 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)10 NetworkVO (com.cloud.network.dao.NetworkVO)9 NicVO (com.cloud.vm.NicVO)9 ReservationContext (com.cloud.vm.ReservationContext)9 DeploymentPlan (com.cloud.deploy.DeploymentPlan)8 HostVO (com.cloud.host.HostVO)8 Volume (com.cloud.storage.Volume)8 Commands (com.cloud.agent.manager.Commands)7 DomainRouterVO (com.cloud.vm.DomainRouterVO)7 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)6 ArrayList (java.util.ArrayList)6 NetworkTopology (org.apache.cloudstack.network.topology.NetworkTopology)6