use of com.cloud.vm.VirtualMachine in project CloudStack-archive by CloudStack-extras.
the class StartSystemVMCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Vm Id: " + getId());
VirtualMachine instance = _mgr.startSystemVM(getId());
if (instance != null) {
SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to start system vm");
}
}
use of com.cloud.vm.VirtualMachine in project CloudStack-archive by CloudStack-extras.
the class StopSystemVmCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
UserContext.current().setEventDetails("Vm Id: " + getId());
VirtualMachine result = _mgr.stopSystemVM(this);
if (result != null) {
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to stop system vm");
}
}
use of com.cloud.vm.VirtualMachine 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.VirtualMachine in project cloudstack by apache.
the class ListLoadBalancerRuleInstancesCmdByAdmin method execute.
@Override
public void execute() {
Pair<List<? extends UserVm>, List<String>> vmServiceMap = _lbService.listLoadBalancerInstances(this);
List<? extends UserVm> result = vmServiceMap.first();
List<String> serviceStates = vmServiceMap.second();
if (!isListLbVmip()) {
// list lb instances
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
if (result != null) {
vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
for (int i = 0; i < result.size(); i++) {
vmResponses.get(i).setServiceState(serviceStates.get(i));
}
}
response.setResponses(vmResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
ListResponse<LoadBalancerRuleVmMapResponse> lbRes = new ListResponse<LoadBalancerRuleVmMapResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
List<LoadBalancerRuleVmMapResponse> listlbVmRes = new ArrayList<LoadBalancerRuleVmMapResponse>();
if (result != null) {
vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Full, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
List<String> ipaddr = null;
for (int i = 0; i < result.size(); i++) {
LoadBalancerRuleVmMapResponse lbRuleVmIpResponse = new LoadBalancerRuleVmMapResponse();
vmResponses.get(i).setServiceState(serviceStates.get(i));
lbRuleVmIpResponse.setUserVmResponse(vmResponses.get(i));
//get vm id from the uuid
VirtualMachine lbvm = _entityMgr.findByUuid(VirtualMachine.class, vmResponses.get(i).getId());
lbRuleVmIpResponse.setIpAddr(_lbService.listLbVmIpAddress(getId(), lbvm.getId()));
lbRuleVmIpResponse.setObjectName("lbrulevmidip");
listlbVmRes.add(lbRuleVmIpResponse);
}
}
lbRes.setResponseName(getCommandName());
lbRes.setResponses(listlbVmRes);
setResponseObject(lbRes);
}
}
use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class VirtualNetworkApplianceManagerImpl method finalizeStop.
@Override
public void finalizeStop(final VirtualMachineProfile profile, final Answer answer) {
if (answer != null) {
final VirtualMachine vm = profile.getVirtualMachine();
final DomainRouterVO domR = _routerDao.findById(vm.getId());
processStopOrRebootAnswer(domR, answer);
final List<DomainRouterVO> routers = _routerDao.listByVpcId(domR.getVpcId());
for (final DomainRouterVO domainRouterVO : routers) {
s_logger.info("Updating the redundant state of router " + domainRouterVO);
updateRoutersRedundantState(domainRouterVO);
}
}
}
Aggregations