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;
}
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);
}
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);
}
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));
}
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);
}
Aggregations